What is structured output?

Structured output constrains a large language model to return data conforming to a predefined schema—such as JSON with typed, required fields—instead of free-form prose. Validating every reply against that schema lets downstream application code, UI cards, and databases consume agent results reliably without brittle text parsing.

By Sacha Arbonel, Founder and CTOLast updated
  • Also called
  • JSON output
  • Output schema

Why does structured output matter?

Free-form paragraphs break parsers whenever a model adds a polite preamble or changes punctuation. Enforced output schemas turn natural-language reasoning into predictable contracts your application can safely render or store.

When an agent’s output feeds your application, free text isn’t enough. Structured output asks the model to reply in a defined schema, for example a draft with a recipient, subject and amount, and checks the reply against it.

Validating every reply catches the cases where a model drifts from the format before they reach your code.

Key characteristics of structured output

  • Defines exact field names, data types, enums, and required properties (often with JSON Schema).
  • Eliminates fragile regular expressions and string splitting on model prose.
  • Validates every response at runtime so malformed payloads fail loudly before corrupting downstream state.
  • Pairs naturally with typed UI components like invoice drafts, triage tags, or approval cards.

Structured output vs. free-text output

DimensionStructured outputFree-text output
Format guaranteeValidated against an explicit schemaUnpredictable prose and formatting
Downstream consumptionDirectly parsed by code, APIs, or UI cardsBest for human reading in chat
Error detectionSchema check catches missing or wrong fieldsSilent drift until a human notices
Evaluation easeSimple deterministic assertions per fieldRequires rubric or human review

Example in practice

How Norilu handles structured output

Frequently asked questions

Does structured output guarantee the content inside the JSON is factually true?
No. Schema validation guarantees the shape and types of the response, not factual accuracy. You still need grounded tools and evaluations to verify correctness.
What should happen when a model reply fails schema validation?
Catch the validation error at the runtime boundary, optionally retry once with the validation error message, and surface an explicit error rather than passing broken JSON to your app.

Go deeper