May 17, 2025

How to improve the output of a single data field when using n8n

Chatgpt has some good ideas on cleaning up an output field for a work flow that sends the output via email

Need to try this on Monday

If all the data is coming in as one field (e.g., a large JSON string or multiline text blob), here’s how you can better format it in n8n:




Option 1: Parse JSON or Text (If Applicable)

If it’s a JSON string:

1. Add a Function node:

const data = JSON.parse($json[“yourFieldName”]);
return [{ json: data }];

This will break the large string into structured fields for cleaner access and formatting.






Option 2: Clean or Format Text Output

If it’s just text (not valid JSON), use a Function node to manipulate it:

const raw = $json[“yourFieldName”];
const formatted = raw
  .split(‘\n’)                      // Split by lines
  .map(line => line.trim())        // Trim whitespace
  .filter(line => line)            // Remove empty lines
  .join(‘\n• ‘);                   // Add bullet points

return [{ json: { formattedText: ‘• ‘ + formatted } }];

This will turn a big blob into a nicely bulleted list.




Option 3: Markdown Output (e.g., for Slack or Email)

Wrap it in Markdown for readable output:

return [{
  json: {
    message: `**Formatted Output**\n\n${$json[“yourFieldName”]}`
  }
}];




If you paste the actual structure of your field (or an example), I can give you a tailored formatting script. Want to share a sample?

Jason Benway

Christ follower, husband, father, IT geek, and Xbox gamer

View all posts by Jason Benway →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.