nodes / builtin / datatransformation
JSON
Parse, build, pick from and repair JSON
Parse, build, pick from, merge and repair JSON.
What it does
Section titled “What it does”The JSON node has five operations:
- Parse turns JSON text into data the next nodes can use. With Repair If Needed on (the default), it first fixes nearly-valid JSON.
- Stringify turns data into JSON text, indented when Pretty Print is on.
- Pick by path reads one value with a dot path, such as
product.offers.price. - Merge deep-merges Merge With into the JSON. Objects are merged key by key; lists and plain values are replaced, and Merge With wins on conflicts.
- Repair fixes JSON text without parsing it, and reports what it changed.
Repair undoes a fixed set of common mistakes, in this order: a Markdown code fence around the JSON, text before or after it, // and /* */ comments, single quotes, keys without quotes, trailing commas, and a cut-off end. It stops as soon as the text is valid. It never invents values: a cut-off end is closed, and a key whose value never arrived is dropped. Valid JSON is never changed.
When to use it
Section titled “When to use it”- Read an AI model’s answer that should be JSON but comes wrapped in a code fence or has a trailing comma.
- Turn JSON-LD from Get Structured Data into fields you can address.
- Build a JSON string for an API body or a file with Stringify.
- To keep or drop whole fields of an item, Edit Fields or Pick Field are simpler.
Inputs and settings
Section titled “Inputs and settings”| Setting | Type | What it does |
|---|---|---|
| Operation | Choice | What to do with the JSON. Options: Parse, Stringify, Pick by path, Merge, Repair. Default: Parse |
| JSON | Value | The JSON text or data to work on. |
| Source Field | Text | Field on the incoming item to read, when JSON above is left empty. |
| Path | Text | Dot path to read, for example product.offers.price. |
| Merge With | Value | The object merged into the JSON. Its values win on conflict. |
| Repair If Needed | Toggle | Try to fix nearly-valid JSON before parsing it. Default: On |
| Pretty Print | Toggle | Indent the output of Stringify. Default: Off |
| Put Result In Field | Text | Name of the field holding the answer. Default: data |
The node finds its input in this order: the JSON field (for example {{ $input.output }}), then the field named in Source Field (dots allowed), then the whole incoming item.
Repair If Needed also applies to text given to Stringify, Pick by path and Merge, since that text is parsed first.
Outputs
Section titled “Outputs”-
Output
- Parse: a parsed object becomes the item itself, so you can use
{{ $input.title }}directly. A list becomes one item per entry. Any other value goes in Put Result In Field. When repair was needed, a_repairedfield lists the fixes. - Stringify: the JSON text, in Put Result In Field.
- Pick by path and Merge: an object result becomes the item; anything else goes in Put Result In Field.
- Repair: the fixed text in Put Result In Field, plus
repaired(whether anything changed),steps(the fixes applied, such ascodeFenceortrailingCommas) andvalid(whether the text now parses).
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- A Basic LLM Chain is asked to answer with a JSON object holding
titleandtags. - JSON with Operation Parse, JSON set to the model’s answer, and Repair If Needed on. A reply wrapped in a code fence still parses.
- Notion creates a page titled
{{ $input.title }}.
Common issues
Section titled “Common issues”- “This is not valid JSON: … Turn on “Repair If Needed” to try to fix it.“ The text is broken and repair is off. Turn Repair If Needed on.
- “This could not be read as JSON even after repair: …” The text is more than nearly valid, for example plain prose with no braces. Ask the model for JSON only, or check the field you read.
- “Path “…” does not exist in this JSON.“ Compare Path with the real structure. List entries use their number, for example
items.0.name. - “Merge needs something to merge in. Fill in “Merge With”.“ Fill in Merge With.
- “Repair works on JSON text. This input is already parsed data.” The input is already data, so there is nothing to repair. Use Parse or Pick by path instead.
Related nodes
Section titled “Related nodes”- Edit Fields: set, rename or remove fields.
- Pick Field: keep one field of an item.
- Structured Output Parser: ask an AI node for JSON in a fixed shape.
- Code: for transformations no node covers.