Fix “JSON parameter needs to be valid JSON” in n8n
What this error means
When the HTTP Request body is set to JSON, n8n builds the final text from your template and expressions, then checks it is valid JSON before sending. If an expression inserts text with quotes or line breaks, or a value without quotes, the result breaks the JSON.
Common causes
- A value contains double quotes or line breaks (customer messages, addresses, AI output).
- A text expression is inserted without surrounding quotes:
"name": {{ $json.name }}. - A trailing comma or a missing brace in the template.
- An expression returns an object, which turns into
[object Object]inside the text.
How to fix it
- Switch the body field to expression mode and build the whole body with
JSON.stringify()— it escapes quotes and line breaks for you. - Or, keep the template but wrap each text value:
"note": {{ JSON.stringify($json.note) }}(no extra quotes). - Use Using Fields Below instead of raw JSON when the body is simple key/value pairs.
- Open the node's input and copy a real value with quotes in it to test before activating.
❌ Breaks
{
"name": "{{ $json.name }}",
"note": "{{ $json.note }}"
}✅ Works
{{ JSON.stringify({ name: $json.name, note: $json.note }) }}💡 Pro tip: AI model output is the most common source of this error — always pass it through JSON.stringify() before putting it in a request body.
🧪 Fix it yourself
A customer's note contains quotes and a line break, which breaks the HTTP Request body. Build the body so it is always valid JSON.
{
"name": "Omar",
"note": "Call me \"after 5\"\nThanks"
}
⚙️ Your fix is executed against both test items — any correct solution passes.
✅ Solution
Output: {"name":"Omar","note":"Call me \"after 5\"\nThanks"}