# Structured Output (LLM)

> The model's answer must fit a set shape, like JSON with set fields.

**Field:** Artificial Intelligence  
**Category:** Working with AI  
**Also known as:** Structured Outputs, Schema-Constrained Output

## Think of it like

Think of it like a form with boxes. The answer has to go in the right boxes.

## Definition

Structured output makes a model's answer follow a fixed shape, most often JSON that matches a schema you give. A schema lists the fields, their types and which ones are needed. Many model APIs can enforce it, so the reply always fits. That lets a program read the answer with no guessing. Without it, a model may add chatty text or drop a field, and the program breaks.

## Example

Lucy's app reads receipts. She asks for JSON with a shop, a date and a total. Every reply has those three fields, so her code can save them straight to a database.

## Example code

```json
{
  "shop": "Corner Bakery",
  "date": "2026-03-14",
  "total": 12.40
}
```

The reply fits the shape the app asked for, so code can read each field.

## Why it matters

It is what lets a program use a model's answer safely. Free text is hard for code to read.

## Common mistake

Checking only that the reply is valid JSON. The fields can still hold wrong values, so check those too.

## Three principles

- **A fixed shape.** Fields set in advance.
- **Enforced by the API.** Replies always fit.
- **Code can read it.** No guessing.

## Related terms

- [JSON Mode](https://learn.benibix.com/term/ai/json-mode)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)
- [Prompt (AI)](https://learn.benibix.com/term/ai/prompt)
- [Tool Use (Function Calling)](https://learn.benibix.com/term/ai/tool-use)
- [Information Extraction](https://learn.benibix.com/term/ai/information-extraction)
- [MCP Structured Tool Output](https://learn.benibix.com/term/ai/mcp-structured-tool-output)
- [Pydantic AI](https://learn.benibix.com/term/development/pydantic-ai)

## Told apart from

- [Structured Output vs MCP Structured Tool Output](https://learn.benibix.com/compare/structured-output-vs-mcp-structured-tool-output): People think both mean the model writes neat JSON. Only one does. Structured output is a model's own answer, forced into a set shape. MCP structured tool output is data a tool sends back after it runs, in a field called structuredContent. The model did not write it at all. One shapes what the model says, the other shapes what a tool returns.
- [JSON Mode vs Structured Output](https://learn.benibix.com/compare/json-mode-vs-structured-output): People think JSON mode makes a model's reply fit their schema, and it does not. JSON mode only makes sure the reply is valid JSON, so a program can open it. The fields can still be missing or named in another way. Structured output checks the reply against the schema you give, so every field you asked for is there. Neither one checks that the values are true.

## Taught in

- [Structured Output and JSON](https://learn.benibix.com/learn/ai-working-with-ai/structured-output-and-json): Prompt Engineering, 10/16

![Two replies to the same request. A free text reply goes to a person to read. A reply in a set shape, with the fields shop, date and total, goes straight into a program.](https://learn.benibix.com/diagrams/pr-structured-output.svg)

---

Source: https://learn.benibix.com/term/ai/structured-output
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
