How it works
JSON mode is a parameter offered by LLM providers (OpenAI, Anthropic, Google, etc.) that instructs the model to respond with only valid JSON. The model cannot include free text before or after the JSON.
Implementation varies: some providers use response_format: {type: "json_object"}, others use tool calling or constrained decoding. The result is always syntactically valid JSON, but the internal structure (fields, types) is not guaranteed.
For that reason, JSON mode is the minimum for integration. To ensure that fields and types match what is expected, use structured output, which combines JSON mode with schema validation.
Practical example
Without JSON mode, a model may respond: "Sure! Here is the result: {\"nome\": \"João\", \"idade\": 30}. Hope it helps!" Code that tries to parse that as JSON will fail.
With JSON mode, the model responds only: {"nome": "João", "idade": 30}. No extra text, no markdown, no explanation. The JSON is valid and can be parsed directly.
But the model may respond {"name": "João", "age": 30} instead of {"nome": "João", "idade": 30}, if there is no clear instruction. JSON mode does not control field names.
What it is for
It serves as a first step to integrate LLMs with code: it guarantees that the response is parseable. It is useful when you need JSON but do not want the complexity of defining a full schema.
Difference between JSON mode and structured output
JSON mode only guarantees that the output is valid JSON. Structured output guarantees that the output is valid JSON AND follows a specific schema (fields, types, requiredness). JSON mode is the floor; structured output is the ceiling.