Study FAQ
When should I use Claude structured outputs instead of asking for JSON in a prompt?
Also asked as 2
- How do I choose between a Claude JSON response schema and strict tool inputs?
- What does Claude structured output guarantee for an application that needs machine-readable data?
Answer
Use Claude JSON outputs when downstream code needs a defined response shape. Use strict tool use when Claude proposes arguments for a registered tool. On a supported Claude API model, the first uses output_config.format with type: "json_schema" and the second sets strict: true on the tool. Both can be used together. Plain text is appropriate when a person reads the response and no machine-readable contract is needed. Claude structured outputs
The supported schema constrains ordinary completed output. A refused or token-limited JSON response can fall outside the schema, and string enum or const values can vary in capitalization even on normal completions. That casing exception also applies to strict tool input. Claude structured outputs
Design a narrow, versioned contract from the consumer's next decision. A support classifier can require a category from a closed list, source evidence references, a concise summary, and a review flag. Specify required fields, permitted values, nested types, and how null or omitted values are handled. Use field descriptions for meaning and check the API's supported JSON Schema subset. For example, some SDK helpers remove unsupported length or numeric constraints from the API schema and validate them locally, so inspect the schema and your SDK's behavior. Claude structured outputs
Schema conformance establishes shape. Check that references resolve to authorized records, the evidence supports the category, and the current state permits the action. A review flag can route a draft to a person. Authorization remains an application decision. Mitigate jailbreaks and prompt injections
Full explanation
Structured Claude Outputs, Validation, and Defensive Parsing
Study guide · CCDV-F
Read the full explanation