New Tool Radar

AI Agents & Automation

How to Add a Structured Output Parser to an n8n AI Agent

Add a structured output parser to an n8n AI agent so its answer comes back as named fields, not a paragraph.

Schematic with three steps: Turn on Require Specific Output Format; Connect a structured output parser; Run the test input and map the.

When an n8n AI agent answers in free text, the next node has to guess where the useful part is. Turn on Require Specific Output Format on the AI Agent node and connect a structured output parser, and the answer arrives as named fields you can map into later steps. This is what makes a hand-off to another node, or another agent, survive: the fields are fixed even when the wording changes.

What you need

  • An n8n workflow with a working AI Agent node and chat model
  • The field names the next step needs, for example category and summary
  • One test input with a known correct answer

Step 1: Turn on Require Specific Output Format

Open the AI Agent node and turn on Require Specific Output Format, so the agent must answer in the shape you define instead of free text.

Step 2: Connect a structured output parser

On the Output Parser connector, add a structured output parser and define the fields: name, type and a short description of each. Keep the list short, with only the fields the next step needs.

Step 3: Run the test input and map the fields

Run the workflow with the test input and check the output has every field with the right type and value. Map the fields into the next node and confirm the downstream step reads them correctly.

Worked example: synthetic classification output

The table below is a synthetic example. It shows the expected result of structured output; no workflow was run.

Field Expected value Returned?
category billing Yes
summary One sentence Yes
needs_human false Yes
All fields present 3 of 3 Pass

Expected result (UNTESTED). the agent returns all three fields with the right values and types, ready for the next node to map. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A parser only fixes the shape, not the content; a wrong category still passes if it fits the schema.
  • Keep the field list short, because every extra field is another chance for the model to fill it with a guess.
  • If the model cannot fit the schema, the run fails instead of returning a partial answer, so test with awkward inputs too.

Sources

See all