Structured Output
Get structured JSON output from Claude: constrained generation, schema validation, and reliable data extraction patterns.
Last updated
After this section you can
- Rank the ways to get JSON from a model and say which have expired on current Claude models
- Get schema-valid output with output_config.format, messages.parse() or strict tools, and pick between them
- Validate business rules the schema cannot express, with a bounded repair loop
Structured Output: JSON Every Time
“How do you make an LLM always return valid JSON?” is a standard interview question. On Claude the answer is a schema the API enforces, plus validation in your code for everything a schema cannot say.
Give the API a JSON Schema in output_config.format and the reply is constrained to match it. That guarantees the shape. Whether the values make sense for your business is still your code’s job.