---
title: "Structured output"
slug: "structured-output"
category: "glossary"
tags: ["glossary", "ai-agents", "structured-output", "json", "schema"]
status: "stable"
last_updated: 2026-05-14
summary: "Structured output constrains model responses to a schema (usually JSON) at generation time, so downstream code can parse without text-extraction heuristics."
related:
  [
    "[[ai-agents/structured-output]]",
    "[[prompt-engineering/prompt-design]]",
    "[[glossary/system-prompt]]",
    "[[glossary/few-shot-prompting]]",
    "[[ai-agents/evaluation]]",
    "[[ai-agents/system-prompts]]",
  ]
---

## Overview

This page is the atomic definition. The deep-dive lives at [[ai-agents/structured-output]].

## Definition

Structured output is model output constrained to a schema (usually JSON, occasionally XML or YAML) at generation time. Modern APIs support it natively: OpenAI's `response_format: { type: "json_schema" }`, Anthropic's tool-use JSON schemas, and Google Gemini's `responseSchema` all enforce the schema during decoding so the response is guaranteed to parse. Pydantic, Zod, and JSON Schema are the most common schema definitions. Structured output replaces fragile regex extraction from free-form text with a typed contract.

## When it applies

Use structured output for any model call whose response feeds downstream code: classifications, extractions, function-call arguments, form fills, or multi-field summaries. Skip it for free-form generation (essays, chat responses) where natural prose is the product.

## Example

```json
{
  "type": "object",
  "properties": {
    "priority": { "enum": ["P0", "P1", "P2", "P3"] },
    "categories": { "type": "array", "items": { "type": "string" } },
    "needs_human": { "type": "boolean" }
  },
  "required": ["priority", "categories", "needs_human"]
}
```

## Related concepts

- [[ai-agents/structured-output]] - the deep-dive with schema patterns and pitfalls.
- [[prompt-engineering/prompt-design]] - the broader prompt-design discipline.
- [[glossary/system-prompt]] - the system prompt declares the output contract.
- [[glossary/few-shot-prompting]] - few-shot examples pair with a structured schema.
- [[ai-agents/evaluation]] - evaluation of structured output is cheap (exact-field match).

## Citing this term

> See [[glossary/structured-output|Structured output]] (llmbestpractices.com/glossary/structured-output).

## Related

- [[ai-agents/structured-output]]
- [[prompt-engineering/prompt-design]]
- [[ai-agents/evaluation]]
- [[glossary/system-prompt]]
- [[glossary/few-shot-prompting]]
