format

JSON mode (structured output)

JSON mode forces a language model to emit only syntactically valid JSON, usually conforming to a schema you supply.

Most major APIs (OpenAI `response_format`, Anthropic via tool-use, Gemini `response_schema`) let you guarantee the model's reply parses as JSON, and increasingly that it matches a JSON Schema. Constrained decoding makes this deterministic — the model literally cannot emit invalid syntax — eliminating retry loops for downstream code. Use it for extraction, classification, form-filling, and tool-call arguments. The trade-off is slightly more rigid responses and occasional schema confusion on complex nested structures.

When to use json mode (structured output)

Common mistakes

FAQ

What is json mode (structured output)?

JSON mode forces a language model to emit only syntactically valid JSON, usually conforming to a schema you supply.

When should I use json mode (structured output)?

Feeding model output into deterministic downstream code. Extraction tasks (resume → JSON, invoice → JSON). Form-style UIs where the model fills fields.

What are the most common mistakes with json mode (structured output)?

Over-specifying — deeply nested schemas confuse smaller models. Using JSON mode without specifying the schema — "valid JSON" alone still drifts.

Last updated: 2026-06-01. Raw markdown: https://promtable.com/glossary/json-mode.md.