PaPoo
cover

What is structured output (JSON mode)?

Structured output, often called JSON mode, is a way to ask an LLM to return data in a fixed machine-readable format instead of free-form text.

Why it matters

When you want an answer that another program can safely parse, plain chat text is fragile. A model might add extra words, change field names, or wrap the result in an explanation.

Structured output helps when you need:

In practice, teams reach for it when they want the model to behave more like a data generator than a conversational assistant.

How it works

There are two closely related ideas:

  1. JSON mode: the model is constrained to emit valid JSON text.
  2. Structured outputs / schema-constrained output: the model is constrained not just to JSON, but to JSON that matches a specified structure, such as required keys, types, and nesting.

Official implementations vary by provider, but the general mechanism is the same: you give the model instructions plus a format constraint, and the system either:

This is different from “please respond in JSON” in plain natural language. A prompt alone may help, but it does not guarantee correctness. Structured output features exist to make that guarantee much stronger.

A useful mental model: the model is still generating text, but the platform is steering or checking that text against a contract.

Tiny concrete example

Suppose you want to extract a support ticket summary:

Request

Return JSON with keys: priority (low, medium, high), category, and summary.

Response

{
  "priority": "high",
  "category": "billing",
  "summary": "Customer was charged twice for the same invoice."
}

That output is easy for your code to parse because the shape is predictable.

Common pitfalls / when NOT to use it

Common pitfalls / when NOT to use it.

Related terms

同じ著者の記事