Inference · beginner
JSON Mode
JSON mode is a provider-specific feature that forces the model to emit syntactically valid JSON. Stronger than asking nicely; weaker than full structured output with a schema.
Explanation
OpenAI introduced JSON mode in late 2023 as a guarantee of valid JSON syntax — but not necessarily JSON that matches your intended shape. Structured Outputs (2024) added schema enforcement on top.
JSON mode is the right tool when you need any valid JSON (e.g. an open-ended classification) and don't want to manage a strict schema. For anything where a downstream parser expects specific fields, prefer full structured output.
Examples
- OpenAI `response_format: { type: "json_object" }`.
- Anthropic Claude with a "respond only in JSON" system prompt + tool use.
Frequently asked
What is JSON Mode?
JSON mode is a provider-specific feature that forces the model to emit syntactically valid JSON. Stronger than asking nicely; weaker than full structured output with a schema.
What is an example of json mode?
OpenAI `response_format: { type: "json_object" }`.
How is JSON Mode related to Structured Output?
JSON Mode and Structured Output are both inference concepts. Structured output constrains an LLM to emit text matching a schema — usually JSON. The model can be guaranteed to produce valid output that your code can parse without retries.
Is JSON Mode considered beginner?
JSON Mode is generally considered beginner-level material in the AI and LLM space.