Structured output
Structured output is any production prompt pattern that forces a language model to return data in a deterministic, machine-parseable form (JSON, XML, custom).
In more detail
What it means
Structured output is the umbrella term for JSON mode, json_schema, XML tagging (Claude), tool-call arguments, and any other constraint that makes the model's output parseable by downstream code without retries. In 2026 the most reliable form is JSON Schema-constrained decoding (OpenAI's strict mode, Anthropic via tool use, Gemini's response_schema) — the model literally cannot emit invalid output. This is the production-grade replacement for 'return JSON' prompting plus regex fallbacks. In practice, keep schemas flat, restrict enums to values the model must choose between, and validate every payload server-side before it reaches business logic, because constrained decoding guarantees shape but cannot guarantee that the chosen values are factually correct for the task.
Part 1 of 2
When to use it, and when not
Use it for
- Any output that downstream code parses.
- Extraction, classification, form-filling, tool arguments.
Part 2 of 2
Common mistakes
- Asking for JSON in the system prompt without a schema.
- Schemas with deeply nested unions — smaller models get confused.
FAQ
Questions readers ask.
What is structured output?
Structured output is any production prompt pattern that forces a language model to return data in a deterministic, machine-parseable form (JSON, XML, custom).
When should you use structured output?
Any output that downstream code parses. Extraction, classification, form-filling, tool arguments.
What are the common mistakes with structured output?
Asking for JSON in the system prompt without a schema. Schemas with deeply nested unions — smaller models get confused.
Last updated: 2026-09-18. Raw markdown: https://promtable.com/glossary/structured-output.md. Found a mistake? Tell us.