9 min read

Structured Outputs in 2026: OpenAI vs Claude vs Gemini

All major LLM APIs now guarantee schema-valid JSON. Compare parameters, JSON Schema support and limits, and why outputs stay JSON while inputs can be TOON.

By json2toon.co

OpenAI, Anthropic and Google all let you constrain a model's response to a JSON Schema. OpenAI uses text.format with strict: true, Claude uses output_config.format, and Gemini uses response_format with a schema. They differ in which schema keywords they accept, their limits, and how strongly they guarantee compliance.

What are structured outputs?

Structured outputs constrain token generation so the response matches a JSON Schema you provide. This is stronger than JSON mode. OpenAI's structured outputs guide puts it this way: "While JSON mode ensures that model output is valid JSON, Structured Outputs reliably matches the model's output to the schema you specify."

Anthropic's docs explain the mechanism: schemas are compiled "into a grammar that constrains Claude's output." All three providers support two forms: a schema for the final response, and strict schemas for tool or function arguments.

OpenAI vs Claude vs Gemini: structured outputs compared

FeatureOpenAIClaudeGemini
Response parametertext.format (Responses) or response_format (Chat Completions), type: "json_schema"output_config.format, type: "json_schema"response_format with mime_type: "application/json" and schema
Strict toolsstrict: true on functionsstrict: true on tools, max 20 per requestFunction calling, combinable with structured output on Gemini 3
All fields required?YesNo, but max 24 optional paramsNo
additionalPropertiesMust be falseMust be falseBoolean or schema
Recursive schemasSupportedNot supportedSupported ($ref: "#")
Numeric limits (minimum, maximum)SupportedNot sent; SDKs validate client-sideSupported
Array size limitsSupportedminItems 0 or 1 onlyminItems, maxItems
Documented size limits5,000 properties, 10 nesting levels, 1,000 enum values, 120,000 chars20 strict tools, 24 optional params, 16 union params, 180 s compile timeoutNone published; "very large or deeply nested schemas may be rejected"
RefusalsSeparate refusal fieldstop_reason: "refusal"Not covered on the structured output page

Sources, all checked October 2026: OpenAI structured outputs, Claude structured outputs, Gemini structured outputs.

How do OpenAI structured outputs work?

In the Responses API, you pass text: { format: { type: "json_schema", name, strict: true, schema } }. Chat Completions uses response_format with the same schema wrapped in json_schema. The rules are the strictest of the three: the root must be an object and "not use anyOf," every field must be listed as required (use a null type for optional values), and additionalProperties: false must always be set.

In exchange, OpenAI supports the widest set of keywords: pattern, string formats, numeric limits, definitions and recursion. Outputs are produced "in the same order as the ordering of keys in the schema," which matters if you put a reasoning field before the answer. Composition keywords such as allOf, not and if/then/else are not supported.

How do Claude structured outputs work?

Claude structured outputs are generally available on the Claude API, Amazon Bedrock, Google Cloud and Microsoft Foundry, with no beta header. Use output_config.format with type: "json_schema" for responses, or strict: true on a tool. Both share the same schema rules.

Claude's list of unsupported features is longer: recursive schemas, numeric constraints, minLength/maxLength, array constraints beyond minItems of 0 or 1, and any additionalProperties value other than false. The SDKs soften this. They remove unsupported constraints, add them to the field description, and validate the response client-side. A minimum: 100 becomes a plain integer on the wire, with the check done by the SDK.

The limits are about grammar compilation: 20 strict tools, 24 optional parameters and 16 union-type parameters per request, plus a 180-second compilation timeout. Compiled grammars are cached for 24 hours from last use, so expect extra latency only on a schema's first request. One subtle catch from the docs: enum values that differ only in capitalization can come back with the wrong case, so compare them case-insensitively.

How do Gemini structured outputs work?

Gemini's current docs use the Interactions API: response_format with type: "text", mime_type: "application/json" and your JSON Schema in schema. Gemini supports a documented subset that includes minimum, maximum, minItems, maxItems, prefixItems, nullable type arrays, and recursion through $ref.

Google is more cautious about guarantees. The docs say: "While output is syntactically correct JSON, always validate values in your application," and list as limitations that "not all JSON Schema features are supported" and "very large or deeply nested schemas may be rejected." Validate every response, as you would with the others.

Why should outputs stay JSON when inputs can be TOON?

Input and output have different jobs. Input data has to be read by the model, so token count and readability matter. Output has to be parsed by your code, so guarantees matter. Structured outputs give you a guarantee for JSON. No provider offers constrained decoding for TOON.

Research points the same way. A February 2026 benchmark (arXiv 2603.03306) found that for generation, plain JSON had the best one-shot and final accuracy, while TOON's strength was comprehension. On the input side, the current official TOON benchmark measured 42.6% fewer tokens than JSON with 72.2% vs 71.4% accuracy over 5,856 calls. For the input side, the JSON to TOON converter turns a sample payload into TOON in your browser.

So the pattern is TOON in, schema-constrained JSON out. Here is a review-classification call. The input data is TOON, generated with @toon-format/toon 4.1.1:

reviews[3]{id,rating,text}:
  101,5,"Setup took two minutes, works great"
  102,2,Battery died after a week
  103,4,"Good value, but the app is clunky"

And the output schema, accepted unchanged by all three providers because it sticks to the common subset (object root, all fields required, enums, additionalProperties: false):

{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "sentiment": { "type": "string", "enum": ["positive", "neutral", "negative"] },
          "topic": { "type": "string", "enum": ["setup", "battery", "price", "software", "other"] }
        },
        "required": ["id", "sentiment", "topic"],
        "additionalProperties": false
      }
    }
  },
  "required": ["results"],
  "additionalProperties": false
}

You can check schemas like this in the JSON Schema validator before you send them. For per-model guidance, see Claude Opus and Sonnet 5.5 data prompts and GPT-5.6 Sol, Terra and Luna with structured data.

How to write one schema that works everywhere

  • Use an object root, never a top-level anyOf.
  • List every property in required. Express optional values as ["string", "null"].
  • Set additionalProperties: false on every object.
  • Avoid recursion, numeric ranges and length limits in the schema. Validate them in code.
  • Keep union types and optional fields few. They drive Claude's grammar limits.
  • Validate responses anyway, and handle refusals and max_tokens truncation.

Schemas also cost input tokens on every call, like tool definitions. See the hidden token cost of tool schemas.

Frequently Asked Questions

Does Claude support structured outputs?

Yes. Claude structured outputs are generally available on the Claude API, Amazon Bedrock, Google Cloud and Microsoft Foundry. Pass a JSON schema in output_config.format with type json_schema for JSON responses, or set strict: true on a tool definition to guarantee schema-valid tool inputs.

What is the difference between JSON mode and structured outputs?

JSON mode only guarantees syntactically valid JSON. Structured outputs constrain generation to your JSON Schema, so required keys are present and enum values are valid. OpenAI recommends structured outputs over JSON mode wherever the model supports it.

Which provider supports the most JSON Schema features?

It depends on the feature. Gemini documents minimum, maximum, minItems and maxItems. OpenAI supports recursive schemas, pattern and numeric constraints but requires every field to be required. Claude does not support recursive schemas, numeric constraints or string-length limits, though its SDKs move those into descriptions and validate them client-side.

Should the model output TOON instead of JSON?

Usually no. Structured outputs give you guaranteed, schema-valid JSON, and no provider offers constrained decoding for TOON. Independent research also found plain JSON more accurate for generation. Use TOON for large input data and keep the output as structured JSON.

Recommended Reading

Structured OutputsJSON SchemaOpenAIClaudeGeminiFunction Calling