JSON from Text
Description
Section titled “Description”AI models often return JSON wrapped in text: a ```json block, a sentence before and after, typographic quotes or a stray trailing comma. The JSON from Text node finds the first well-formed JSON object or list inside the text, turns it into data and, if you want, checks it has the required fields.
If you don’t set the field holding the text, the node uses the input itself or the first usual field of an AI or HTTP response: contenido, content, text, output, response, respuesta, message, result, reply (and choices[0].message.content). If the field already holds an object, it lets it through as is.
Configuration
Section titled “Configuration”| Parameter | Type | Required | Description |
|---|---|---|---|
| path | text | No | Path to the text containing the JSON. Empty = the input or the first usual field |
| expect | select | No | auto (whatever is there), object (only an object { }) or array (only a list [ ]) |
| requiredFields | text | No | Comma-separated required fields (paths like author.name work). If any is missing or empty, the result is invalid |
| fallbackField | text | No | If the AI answers with plain text and no JSON, the whole text is used as this field (for example contenido_html) instead of failing, and jsonRespaldo: true is returned. Required fields are still checked |
| onInvalid | select | No | error (default: stops the run with an error) or continue (goes on with jsonOk = false) |
| errorMessage | text | No | Text that heads the error when it stops |
| spread | boolean | No | Besides the output field, copies each field of the object to the top level ({{title}} instead of {{json.title}}) |
| outputKey | text | No | Field where the JSON is stored (default json) |
Output
Section titled “Output”The node keeps the incoming data and adds:
{ "contenido": "Here you go: ```json {\"title\":\"Hello\"} ```", "json": { "title": "Hello" }, "jsonOk": true}With onInvalid: continue and an invalid result: jsonOk is false, json is the JSON found (or null) and jsonFaltan lists the required fields that were missing. Use it with a decision node on data.jsonOk.
What it tolerates
Section titled “What it tolerates”```jsonor```blocks, and text before or after.- Braces and brackets inside text strings.
- Trailing commas (
{"a":1,}) and typographic quotes (“ ”). - Several blocks: it ignores the ones that are not valid JSON and takes the first that is (and meets
expect).
Usage Example
Section titled “Usage Example”Article generated by an AI
Section titled “Article generated by an AI”{ "label": "Parse the response", "path": "contenido", "expect": "object", "requiredFields": "title, content_html", "errorMessage": "The AI did not return a usable article", "spread": true}Later nodes can use {{title}} and {{content_html}}. If the AI does not return JSON with those fields, the run stops with a clear message.
Related Nodes
Section titled “Related Nodes”- validate (Validator - to check and clean the content)
- editFields (Edit Fields - to shape the result)
- decision (Decision node - to act on
jsonOk)