Structured Outputs
Structured outputs make the Claude API return JSON that always matches a JSON Schema you supply, through output_config.format, or tool inputs that match exactly, through strict tool use. It is Claude's answer to a JSON mode, generally available since Jan 29, 2026.
Structured outputs make the Claude API return valid JSON that matches a schema you supply: add output_config.format with "type": "json_schema" and a JSON Schema, and Claude's reply is constrained, token by token, to fit it (Structured outputs). The same mechanism, applied to tool arguments, is strict tool use ("strict": true on a tool). Claude has no separate "JSON mode" switch; this is the feature that does that job, and it goes further, since the output must match your exact fields and types rather than merely parse. It works on every current model, launched in beta on Nov 14, 2025 and became generally available on Jan 29, 2026.
Quick facts
| JSON output | output_config.format with type: "json_schema" and a schema |
| Tool inputs | strict: true on a tool definition |
| How | Constrained sampling with a grammar compiled from your schema |
| Models | All current models (Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5) and most older ones back to Sonnet 4.5 |
| Per-request limits | 20 strict tools, 24 optional parameters, 16 union-type parameters |
| First-use delay | Compiling a new schema adds latency; grammars are cached 24 hours from last use |
| Not combinable with | Citations |
| Zero data retention | Eligible |
Sources: Structured outputs and Citations, Anthropic docs, read Nov 6, 2026.
How do you get JSON from Claude?
Put the schema in output_config.format. Anthropic's example pulls contact details out of an email:
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Extract the key information from this email: John Smith (john@example.com) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."}],
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string"},
"plan_interest": {"type": "string"},
"demo_requested": {"type": "boolean"}
},
"required": ["name", "email", "plan_interest", "demo_requested"],
"additionalProperties": false
}
}
}
}'
The answer arrives as a text block containing JSON with those four fields. Required properties are written first, then optional ones, whatever order the schema lists them in.
The SDK helpers
The SDKs turn a native type into a schema and parse the reply back into it. In Python, with Pydantic:
from pydantic import BaseModel
class ContactInfo(BaseModel):
name: str
email: str
plan_interest: str
demo_requested: bool
response = client.messages.parse(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Extract the key information from this email: ..."}],
output_format=ContactInfo,
)
print(response.parsed_output)
TypeScript uses Zod schemas through zodOutputFormat(), and the Java, PHP and Ruby SDKs accept classes; each returns the typed result in parsed_output (Structured outputs). In the Python SDK from version 1.0, passing output_format to a plain create() call raises a TypeError: use parse(), or output_config with a raw schema.
Strict tool use
When Claude calls your functions instead of answering in JSON, add "strict": true to the tool definition and its input will always match the tool's input_schema (Strict tool use). Without it, Claude can occasionally send a string where an integer belongs or skip a required field. Strict tools matter more on the newest models: Opus 5.5, Sonnet 5.5 and Fable 5.1 reject forced tool use (tool_choice any or tool), and Anthropic's suggested replacement is auto plus strict tools (Release notes). The loop itself is on Tool Use.
Which JSON Schema features are supported?
Most of standard JSON Schema works: objects, arrays, strings, numbers, booleans, enums, required, anyOf and $ref within the schema. These return a 400 error (Structured outputs):
- Recursive schemas, and external
$ref. - Numeric limits (
minimum,maximum,multipleOf) and string length limits (minLength,maxLength). - Array limits other than
minItemsof 0 or 1. additionalPropertiesset to anything butfalse.- Regex
patterns with backreferences, lookaround or word boundaries.
Across all strict schemas in one request the totals are capped at 20 strict tools, 24 optional parameters and 16 parameters with union types. A schema too large to compile returns "Schema is too complex for compilation", and compilation gives up after 180 seconds. A common workaround for an unsupported limit is to describe it in the field's description and check it in your code after parsing.
When the output can still be wrong
The schema guarantees shape, not truth: Claude can fill a valid field with a wrong value, so check facts that matter. Two cases also break the shape. If the reply hits max_tokens (stop_reason: "max_tokens"), the JSON is cut off; raise the limit and retry. If Claude refuses (stop_reason: "refusal"), the reply may not match the schema at all. Always read stop_reason before parsing (Messages API).
Limits and compatibility
- The first request with a new schema is slower while the grammar compiles; after that the grammar is cached for 24 hours from last use. Changing the schema means a new compile.
- Structured outputs and citations cannot be used together; the request returns an error (Citations).
- Prefilling a JSON opening brace, an older trick for getting JSON, returns a 400 error on Claude 4.6 and later models, which is part of why structured outputs replaced it (Using the Messages API).
- It works on every platform that sells Claude, including Amazon Bedrock and Google Cloud, and with the Message Batches API. Under zero data retention only the schema is cached, for up to 24 hours.
Frequently asked questions
Does Claude have a JSON mode? Claude has no switch named JSON mode; Claude's structured outputs (output_config.format with a JSON Schema) do the job and guarantee the reply matches your schema, not just that it is valid JSON.
Which Claude models support structured outputs? All current Claude models (Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5) and the older Opus 5, Sonnet 5, Opus 4.8 to 4.5, Sonnet 4.6 and 4.5, and Haiku 4.5 support structured outputs on the Claude API.
What is the difference between Claude structured outputs and strict tool use? Both constrain Claude with your JSON Schema. Structured outputs shape Claude's final answer; strict tool use (strict: true) shapes the arguments Claude passes when it calls one of your tools.
Why does Claude return a 400 error for my schema? The Claude API rejects schema features it cannot compile, such as minimum, maxLength, recursion or additionalProperties: true, and schemas past the limits of 20 strict tools, 24 optional parameters or 16 union-type parameters per request.
Can Claude's structured output still be invalid? Rarely: if Claude stops at max_tokens the JSON is truncated, and a refusal may not follow the schema. Check that stop_reason is end_turn before parsing.
Sources
- Structured outputs, Anthropic docs, read Nov 6, 2026
- Strict tool use, Anthropic docs, read Nov 6, 2026
- Citations, Anthropic docs, read Nov 6, 2026
- Using the Messages API, Anthropic docs, read Nov 6, 2026
- Release notes, Anthropic docs, read Nov 6, 2026
See also
-
Claude APIThe Claude API is Anthropic's REST API at api.anthropic.com for building with Claude models: create an API key in the Claude Console at platform.claude.com, then send requests to the Messages API, paying per token.
-
Tool UseTool use (function calling) lets Claude call functions through the Claude API: you describe tools with a JSON Schema, Claude replies with a tool_use block, your code runs it and sends back a tool_result. Anthropic also runs server tools such as web search itself.
-
Messages APIThe Messages API is the Claude API's main endpoint, POST /v1/messages: you send a model, max_tokens and a list of user and assistant messages, and Claude returns a message with content blocks, a stop_reason and token usage, whole or streamed.
- Message Batches APIThe Message Batches API runs up to 100,000 Claude API requests asynchronously at 50% off the normal price; most batches finish within an hour, every batch within 24 hours, and results stay downloadable for 29 days.
- Claude API PricingClaude API prices are per million tokens, from $0.10 input and $0.50 output on Claude Haiku 5.5 to $10 and $50 on Claude Fable 5.1, with Opus 5.5 at $4 and $20 and Sonnet 5.5 at $2 and $10, as of Nov 6, 2026. Prompt caching and the 50% Batch discount lower that.
- Claude API Rate LimitsClaude API rate limits are set per organization by usage tier (Start, Build, Scale, Custom) as requests, input tokens and output tokens per minute; on the Start tier Claude Opus 5.5 allows 4,000 requests, 2,000,000 input tokens and 400,000 output tokens a minute. Going over returns a 429 error, while a 529 error means the API itself is overloaded.