节点 / builtin / ai / aidependencies / outputparser
Structured Output Parser
Return data in a defined JSON format
此内容尚不支持你的语言。
Make an AI node answer with JSON in the exact shape you give as an example.
What it does
Section titled “What it does”Structured Output Parser is not a step on its own: it has no output port and never runs by itself. You plug it into the Output Parser slot of an AI node, and that node uses it.
From your JSON Output Example, the parser works out the fields and their types (text, number, true/false, lists, nested objects). The AI node then adds formatting instructions to what it sends the model, asking for JSON in that shape. When the reply comes back, the parser reads it and checks it against the shape, so the AI node returns real data instead of text.
When to use it
Section titled “When to use it”- Turn free text into fields you can use later, such as a name, an email and a company.
- Get a fixed set of values back, for example
{ "sentiment": "positive", "score": 0.9 }, to route with an If or Switch. - When the model sometimes breaks the JSON, put an Auto-fixing Output Parser in front of it.
For a plain list of words, Item List Output Parser is simpler.
Inputs and settings
Section titled “Inputs and settings”| 设置项 | 类型 | 作用 |
|---|---|---|
| JSON Output Example (必填) | Code | An example of the JSON output you expect. 默认值:{
"name": "John",
"age": 30
} |
Write a real example, not a description. The value types matter more than the values: "John" means text, 30 means a number, true means true/false, ["a"] means a list of text. For example:
{ "name": "Ada Lovelace", "email": "ada@example.com", "company": "Analytical Engines", "interested": true}The example must be valid JSON: double quotes around names and text, no trailing commas, no comments.
Outputs
Section titled “Outputs”This node has no output port. It plugs into a slot on another node instead of passing items along.
- Output Parser slot of Tools Agent, Q&A Agent, RAG Agent, Basic LLM Chain, Information Extractor
- Base Parser slot of Auto-fixing Output Parser
The data appears on the node it is plugged into. On Basic LLM Chain and the agents, response becomes an object, so you can read single fields downstream, for example {{ $input.response.email }}. On Information Extractor the object is in extracted.
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”- Get Selected Text reads an email signature you highlighted, with Output field name
text. - Basic LLM Chain with Prompt
Extract the contact details from: {{ $input.text }}. Connect an OpenAI model to its Model slot. - Structured Output Parser connected to the Output Parser slot of Basic LLM Chain, with JSON Output Example
{ "name": "Ada Lovelace", "email": "ada@example.com", "company": "Analytical Engines" }. - Display Markdown with Content
{{ $input.response.name }} works at {{ $input.response.company }}.
Common issues
Section titled “Common issues”- The run fails with a JSON error such as “Unexpected token” before the model is called. JSON Output Example is not valid JSON. Fix the quotes and commas.
- “Failed to parse”. The model’s reply was not JSON in the expected shape. Use a stronger model, simplify the example, or wrap this parser in an Auto-fixing Output Parser.
- A field has the wrong type. The type comes from the example value: write
30, not"30", if you want a number.
Related nodes
Section titled “Related nodes”- Auto-fixing Output Parser: retry with a model when the JSON is broken.
- Item List Output Parser: get a simple list instead.
- Information Extractor: pull named fields out of text.
- Basic LLM Chain: one prompt, one structured answer.