Structured Output
- JSON mode
- constrained decoding
- schema-constrained output
What is Structured Output?
Structured output constrains generation to match a supplied schema — typically JSON Schema — by restricting which tokens are valid at each decoding step. The response is guaranteed to parse and to have the declared shape, removing an entire class of integration failure.
In practice
The enforcement happens inside decoding rather than after it. A grammar derived from the schema determines which tokens are legal at each position, and the sampler chooses only among those. Compared with asking politely for JSON and repairing whatever comes back, this eliminates trailing commentary, markdown fences, truncated objects and hallucinated fields — not by validation and retry, but by making the invalid token unreachable.
It is the natural interface between a model and the rest of a system. Extraction pipelines get typed records; classification returns an enum the code can switch on; agent tool arguments arrive already conforming to the function’s signature; UI components can be driven directly from a validated object. Well-named fields and tight types also improve content quality, because the schema is documentation the model reads: an enum of five allowed values produces better decisions than a free-form string field.
The misconception is that valid means correct. The schema constrains form, not truth — a required `confidence` number will always be present and may be meaningless, and a required field the source text does not support invites the model to invent a value rather than leave it out. Make genuinely optional fields optional, add an explicit "not found" representation, and keep semantic validation in code where it belongs.
Related terms
Articles covering this
Where Structured Output shows up in practice rather than in definition.