How To Paste JSON Correctly in n8n

Working with JSON in n8n is a key part of building automated workflows. Whether you’re grabbing API responses, sending data between nodes, or triggering processes with a webhook, knowing how to paste JSON correctly in n8n can save you lots of time and troubleshooting headaches. In this guide, you’ll learn the different ways to paste JSON into n8n—safely and efficiently—without breaking your workflow.

Why Pasting JSON Correctly Matters in n8n

JSON (JavaScript Object Notation) is the universal data format used across APIs, databases, and automation workflows. In n8n, you’ll frequently encounter JSON when working with HTTP requests, webhook payloads, or manually adding test data for workflows.

Improper formatting can result in broken nodes, failed executions, or confusing errors. Understanding exactly how to paste JSON in n8n will ensure your automations run smoothly.

Where You Can Paste JSON in n8n

There are several places in n8n where you might need to paste JSON:

  • In the Function or Set Node to define data manually
  • When Using Webhook Test Data from external tools like Postman
  • In the Code editor for HTTP Request configurations
  • In node parameters like headers or body for custom API calls

Each has slightly different expectations when it comes to JSON formatting.

Let’s walk through the correct approach in each case.

How to Paste JSON in the Set Node

The Set node is often used to manually define structured data for testing or preparing values for other nodes.

Step-by-Step: Pasting JSON in the Set Node

  1. Add a Set Node to your workflow
  2. Click Add Value and select Add Field
  3. Change the value type to JSON
  4. A textbox will appear—paste your JSON directly here

For example, paste the following JSON:

{
  "name": "John Doe",
  "email": "john@example.com"
}

n8n will automatically parse this into proper key-value fields. Just make sure your pasted JSON is:

  • Properly indented
  • Uses double quotes " for keys and strings (single quotes will error)
  • Doesn't have trailing commas

Many JSON formatting issues relate to syntax errors. Always validate your JSON using a tool like JSONLint before pasting.

Best Practice

Try pasting your JSON into a temporary Function or Set node whenever you're unsure how clean it is. This can quickly highlight invisible formatting problems.

How to Paste JSON in the Function Node

The Function node lets you custom script JavaScript. Often, you'll define JSON manually for output.

Example: Returning Raw JSON from Function Node

Here’s how to correctly paste JSON as return data:

return [
  {
    json: {
      id: 123,
      title: "Test Task"
    }
  }
]

In this case, the outer structure is a JavaScript array of objects with a json key—n8n expects this output format for internal data handling.

Tip

If you already have a JSON snippet, strip the outer curly braces if you intend to assign it to a variable. Otherwise, wrap it inside return [{ json: ... }] as shown.

For more in-depth tutorials on using custom nodes, check our guide on installing community node templates in n8n.

How to Paste JSON in HTTP Request Nodes

The HTTP Request node offers places to paste JSON for headers, bodies, and queries.

Here’s how to add raw JSON to the body:

Step-by-Step

  1. Add the HTTP Request node
  2. Select POST as the method
  3. Switch "Body Content Type" to RAW/Custom
  4. Choose JSON as the format
  5. In the JSON Body field, paste your JSON

Example:

{
  "userId": 56789,
  "action": "subscribe"
}

Make sure Content-Type is set to application/json in the headers.

Shortcut Tip

If you have your request body saved in a file or copied from a tool like Postman, paste it directly into the “JSON Body” section—just ensure the quotes are standard double quotes.

Also, consider reading our guide on using bearer authentication in n8n if your API requires tokens.

Pasting JSON for Webhook Testing

While testing Webhook nodes, you'll often simulate real-world data by sending JSON from Postman or another service.

Mini Use Case: Receiving JSON in Webhook

  1. Add a Webhook node and copy the test URL
  2. Use a REST client like Postman to send this JSON in a POST request:
    {
      "event": "new_lead",
      "details": {
     "name": "Sarah",
     "source": "landing_page"
      }
    }
    
  3. Inspect the incoming data in the Execution panel

Once the webhook receives the JSON, n8n automatically exposes the full nested structure in the json tab of the Webhook node's output. You can reference nested values like:

{{$json["details"]["name"]}}

This is extremely useful when building marketing automations or lead flows in n8n.

Common Errors When Pasting JSON in n8n

Let’s break down frequent issues users face and what they mean:

Error Likely Cause
Unexpected token } Extra comma or unmatched bracket
Unexpected string Using single quotes instead of double quotes
Invalid input Malformed JSON or missing opening [ in return

Removing these mistakes through a quick validation step will save you a lot of debugging time.

Best Tools to Format and Paste JSON Smoothly

Here are tools that come in handy:

  • JSONLint: Check JSON validity
  • Quicktype: Convert JSON to typed code, great for creating mock data
  • VSCode or Sublime Text: Use with syntax highlighting and formatters

If you’re regularly pasting JSON in n8n for complex workflows, these tools are essential companions.

Summary Tips For Pasting JSON in n8n

  • Always validate JSON before pasting
  • Use double quotes, never single quotes
  • Choose the right node for the use case: Set, Function, HTTP, etc.
  • Match structure expectations (especially return [{ json: ... }] in Function nodes)
  • Eliminate trailing commas and maintain curly bracket consistency

FAQ

How do I fix “Unexpected token” errors when pasting JSON in n8n?

Double-check your JSON syntax. Common causes include trailing commas, unmatched brackets, or using single quotes instead of double quotes.

Can I paste nested JSON structures in the Set node?

Yes, n8n supports nested objects. You can paste them directly into the value field when adding JSON types in the Set node.

How do I paste JSON from Postman into an HTTP node?

Simply copy the raw body from Postman (in JSON format) and paste it into the "JSON Body" field of the HTTP Request node, making sure "Body Content Type" is set to RAW/Custom.

Is there a way to convert JSON automatically for Function nodes?

You can use tools like Quicktype or JavaScript utilities to wrap your JSON structure correctly into an array with a json property, as required by n8n.

What’s the easiest way to test JSON in a workflow without API calls?

Use the Set node or a Function node to simulate input by pasting your JSON directly. This is useful for early development and debugging.

Mastering how to paste JSON in n8n enables you to streamline your workflows, reduce errors, and optimize data structures across automations. Whether you're working with APIs, mock data, or chatbots, clear JSON input will make your workflow building faster and more reliable.

★★★★★
50+ fixes, templates & explanations
Stuck with n8n errors?
Node-by-node breakdown.
Copy-paste templates.
Beginner friendly.
Get the n8n Beginners Guide
Built by AgentForEverything.com
Comments
Join the Discussion and Share Your Opinion
Add a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Newsletter
Get The Latest Agent Templates & Guides, Straight To Your Inbox.
Join the #1 AI Automation newsletter.