Parse JSON icon

Parse JSON

Parse JSON object from a JSON string

Overview

This node parses a JSON string into a JSON object. It is useful when you have data in string format that represents JSON and you want to convert it into an actual JSON object for further processing within your workflow. The node attempts to handle both clean and somewhat "dirty" JSON strings by applying several cleaning and extraction strategies before parsing.

Common scenarios include:

  • Receiving JSON data as a string from APIs or files that may contain formatting artifacts.
  • Cleaning up JSON strings that include markdown-style code blocks or escaped newlines.
  • Extracting valid JSON objects embedded inside larger text blobs.

Example: You receive a JSON string with markdown code block delimiters (json ... ) and want to parse it into usable JSON data.

Properties

Name Meaning
JSON String The JSON string to parse. Can be clean JSON or somewhat dirty JSON, but it must be valid JSON.

Output

The node outputs the original input data with an added field in each item's json property:

  • jsonObject: The parsed JSON object obtained from the input string.
  • parsingSuccessful: A boolean indicating whether the parsing resulted in a non-empty JSON object.

If the input JSON string cannot be parsed, depending on the node's error handling settings, it either throws an error or continues with an error object attached.

No binary data output is produced by this node.

Dependencies

  • No external services or API keys are required.
  • The node relies on standard JavaScript JSON.parse() and internal string manipulation.
  • No special environment variables or n8n configurations are needed.

Troubleshooting

  • Common issues:

    • Input string is not valid JSON or contains syntax errors.
    • JSON string includes markdown code block delimiters or escaped characters that prevent direct parsing.
    • Partial or malformed JSON embedded in larger text.
  • Error messages:

    • Parsing errors will indicate failure to parse JSON string as is or after cleaning attempts.
    • If manual extraction fails, detailed debug messages are included internally but only surfaced if error handling is enabled.
  • How to resolve:

    • Ensure the input string is valid JSON or at least contains a valid JSON object.
    • Remove extraneous markdown delimiters or escape sequences before passing to the node.
    • Use the node’s built-in cleaning feature by providing JSON strings with minor formatting issues.
    • Enable "Continue On Fail" option to handle problematic inputs gracefully.

Links and References

Discussion