DevKits
Concept

What Are Structured Outputs? Guaranteed JSON from LLMs Explained

Structured Outputs make an LLM return JSON that provably matches a schema you supply. This guide explains how strict mode works, why it beats plain JSON mode, the schema rules you must follow (object root, additionalProperties:false, all-required), and how it relates to function calling.

Last updated:

Core Concepts

The problem Structured Outputs solve
Ask a model for JSON in a prompt and most of the time you get valid JSON — but not always. Occasionally it adds a markdown fence, a trailing comment, a missing field, or a wrong type, and your parser throws in production. Structured Outputs (OpenAI) and equivalent features elsewhere remove that uncertainty: you attach a JSON Schema, and the model is constrained during generation to emit output that matches it. The result is JSON you can parse without defensive retries.
Strict mode vs JSON mode
JSON mode only guarantees the output is syntactically valid JSON — any shape. Structured Outputs strict mode guarantees the output conforms to your specific schema: the right keys, types, and nesting. JSON mode stops parse errors; strict mode stops schema mismatches. If you have a defined shape you depend on, strict mode is what you want.
The strict-mode schema rules
To use strict mode your JSON Schema must obey a subset of the spec: the root must be type: object; every object — including nested ones and objects inside arrays — must set additionalProperties: false; and every property must be listed in required (there are no optional fields). You emulate an optional field by making its type a union that includes 'null'. Several keywords (minLength, pattern, minimum, etc.) are limited or ignored. A schema that breaks these rules is rejected before any tokens are generated.
Emulating optional fields with null
Because strict mode requires every property in 'required', you can't simply omit an optional field. Instead you keep it required but allow null: { "type": ["string", "null"] }. The model always includes the key and returns null when there's no value. This keeps the schema valid while still expressing 'this may be absent'.
Relationship to function / tool calling
The same schema-constraining mechanism powers strict function calling: a tool's parameters schema can be marked strict so the arguments the model produces are guaranteed to match. Structured Outputs apply it to the final response (via response_format); strict tools apply it to tool arguments. Both rely on the same rules, so a schema that passes the strict-mode checks works in either place.

Frequently Asked Questions

What's the difference between Structured Outputs and JSON mode?

JSON mode only promises valid JSON of any shape. Structured Outputs (strict mode) promises JSON that matches your exact schema — correct keys, types, and structure. Use JSON mode when any JSON is fine; use Structured Outputs when you parse into a fixed shape.

Why does my schema get rejected with 'additionalProperties must be false'?

Strict mode requires every object in the schema — including nested objects and objects inside arrays — to explicitly set additionalProperties: false. If any object omits it, the whole schema is rejected. Add it everywhere, or use our Structured Output Schema Checker to find each missing one.

How do I make a field optional in strict mode?

You can't omit it from 'required'. Instead keep the field required and make its type a union with null, e.g. {"type": ["string", "null"]}. The model then always emits the key, using null when there's no value.

Do other providers support Structured Outputs?

Yes, in varying forms. OpenAI has Structured Outputs with strict JSON Schema; Google Gemini supports a responseSchema; Anthropic supports tool-based structured responses. The exact rules differ, but the idea — constrain generation to a schema — is the same.

Try these related tools