The Alternatives Issue For tool owners Sign in

JSON mode (structured output)

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

In more detail

What it means

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. For production use, pair JSON mode with server-side schema validation and a bounded retry, since a syntactically valid payload can still carry a wrong enum value or a missing required field.

Part 1 of 2

When to use it, and when not

Use it for

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

Part 2 of 2

Common mistakes

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

FAQ

Questions readers ask.

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 you 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 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-09-18. Raw markdown: https://promtable.com/glossary/json-mode.md. Found a mistake? Tell us.