Structured outputs
Getting model responses in a reliable machine-readable format.
Structured outputs constrain a model to a schema, such as JSON, so the product can use the result safely. They turn free text into data. Validation and fallbacks still matter when outputs are wrong but well formed.
Why it matters for a product engineer
Free text is hard for code to use. Structured outputs make a model answer in a fixed format, usually JSON that follows a schema, so the product can store, display or act on the result. That turns a model from a writer into a component. But a response can be well formed and still wrong, so the format is only the first check.
How to do it
- Define a schema with the fields your code needs, their types and which are required.
- Use the model provider’s structured output mode, so responses always match the schema.
- Keep fields small and literal: numbers as numbers, lists as lists, dates in one format.
- Allow “unknown” or empty values, so the model is not forced to invent an answer.
- Validate the content too: ranges, allowed values, and facts you can check against the source.
- Decide what happens when validation fails: retry, fall back, or ask a person.
Common mistakes
- Parsing free text with regular expressions.
- Trusting a valid JSON object as a correct answer.
- Required fields with no “unknown” option, which invites invented values.
- Changing the schema without versioning it, so stored results stop matching.
Example
Mamitsu watches a social media video and returns what you ask for as JSON. You send a link and a question in plain words, and you can add a JSON Schema “when your code needs the same fields every time”. The home page shows a cooking reel turned into a recipe an app can use directly. (Mamitsu in In practice)
A cooking reel as JSON, from Mamitsu's home page
{ "dish": "15-Minute One-Pot Creamy Miso Udon",1 "time_minutes": 15,2 "ingredients": ["miso", "peanut butter", "udon noodles", "egg", "spinach"],3 "steps": ["Whisk miso and peanut butter together in a pot.", "Add udon noodles to the broth.", …]4 }
- 1Named fields
- 2A number, not textAn app can sort or filter by it.
- 3A list the app can show
- 4Order keptFrom the video, not only the caption.
The question was plain words. The answer is data: types, lists and order that code can use without guessing.
Observedusemamitsu.com, 23 Nov 2026
Sources: Structured outputs (Claude docs) ↗ · Mamitsu ↗
Technical leverage
Define schemas, validate responses at the boundary and check business constraints before generated data reaches application state.
Evidence of mastery
Put it into practice- Practice
- Extract structured records from varied documents, including missing and contradictory information.
- Artifact
- A schema, validation code and a dataset of accepted, rejected and uncertain results.
What good looks like
- Well-formed but factually wrong output is detected by separate checks.
- Refusals and incomplete output do not silently become valid records.
Use this evidence to assess your work. Your map status is a self-assessment, not a certification.
In practice
Real productsResources
1- docsStart here
Structured outputs ↗
Anthropic docs · 15 minGetting responses that always match a JSON schema, so your code can rely on them.
Tools
2- ToolOpen source
- ToolOpen source
promptfoo
Open-source tool for testing prompts and models against test cases, and for red-teaming LLM apps.