Unsafe JSON parsing in n8n
- Feb 13
- 1 min read
What this means (non-technical)
This occurs when JSON.parse() is used in a Code node without handling possible errors. If the input string is not valid JSON, JSON.parse() throws an exception.
This immediately crashes the workflow.
What usually goes wrong
APIs sometimes return:
Error messages instead of JSON.
Empty responses.
Truncated or malformed data.
When JSON.parse() encounters invalid input:
The workflow stops entirely.
All items being processed are lost.
The error message may not clearly explain the original cause.
This often shows up as “random” crashes when data formats change unexpectedly.
When this becomes urgent
This becomes urgent when:
You parse responses from external APIs.
Data sources are not fully under your control.
Workflows process large volumes.
Failures occur intermittently.
The less predictable the data source, the higher the risk.
Detect issues in your n8n workflows
|
Definitions
JSON.parse(): A JavaScript function that converts a JSON string into an object.
Exception: An error that stops code execution immediately.
Disclaimer
This article highlights common patterns and risks seen in real-world n8n workflows. It’s meant to help you build more confidently and avoid surprises as your automation grows. Behavior can vary depending on your setup, version, and configuration.