> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dottxt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Treat JSON Schema as a generation program, not a formatting hint.

A good schema is a contract between you and the model. The tighter the contract, the less work your application code does. If your schema says `"enum": ["billing", "technical", "account"]`, your routing logic doesn't need a default case. If it says `"minItems": 1`, your code doesn't need an empty-array check. If it says `"pattern": "^[A-Z]{2}$"`, you get country codes, not country names.

Most schemas we see in production are too loose. They define the structure but not the boundaries: no length limits on strings, no bounds on arrays, and no patterns on identifiers. The model fills in reasonable values most of the time, and then once in a thousand requests it produces a 4,000-character "summary" or an array with 200 items, and something downstream breaks.

This section is about writing schemas that don't break. Start with [Improve Your Schema](/json-schema/improve-your-schema) if you have an existing schema, or pick a [domain example](#domain-examples) close to your use case.

## Authoring

Create schemas from the tools you already use.

<Columns cols={2}>
  <Card title="Pydantic" icon="wand-magic-sparkles" href="/json-schema/authoring/pydantic">
    Define models in Python and generate JSON Schema from them.
  </Card>

  <Card title="Zod" icon="wand-magic-sparkles" href="/json-schema/authoring/zod">
    Define schemas in TypeScript with runtime validation.
  </Card>

  <Card title="From sample data (quicktype)" icon="wand-magic-sparkles" href="/json-schema/quicktype">
    Generate schemas from example JSON with quicktype.
  </Card>

  <Card title="From sample data (genson)" icon="wand-magic-sparkles" href="/json-schema/genson">
    Infer a baseline schema from representative JSON instances.
  </Card>

  <Card title="Improve your schema" icon="triangle-exclamation" href="/json-schema/improve-your-schema">
    Turn domain knowledge into constraints that guide generation.
  </Card>
</Columns>

## Patterns

The difference between a schema that works and one that breaks in production usually comes down to a few missing constraints. These patterns address the problems we see most often.

<Columns cols={2}>
  <Card title="String bounds and patterns" icon="book" href="/json-schema/string-bounds">
    Control length, format, and regex patterns on string fields.
  </Card>

  <Card title="Bounded arrays" icon="book" href="/json-schema/bounded-arrays">
    Set min/max item counts to prevent runaway generation.
  </Card>

  <Card title="Optional fields" icon="book" href="/json-schema/optional-fields">
    Truly optional fields that the model can omit entirely.
  </Card>

  <Card title="Unions and discriminators" icon="book" href="/json-schema/union-of-objects">
    Route output to different shapes based on a discriminator field.
  </Card>

  <Card title="Conditional logic" icon="book" href="/json-schema/conditional-requirements">
    Use if/then/else and dependent keywords when requirements vary by context.
  </Card>

  <Card title="Recursive schemas" icon="book" href="/json-schema/recursion">
    Model trees, nested structures, and self-referencing types.
  </Card>

  <Card title="Chain of thought outputs" icon="book" href="/json-schema/chain-of-thought">
    Constrain reasoning-style outputs into structured, inspectable fields.
  </Card>
</Columns>

## Domain examples

Complete schemas for real tasks, with the reasoning behind each constraint choice.

<Columns cols={2}>
  <Card title="Classification" icon="map" href="/json-schema/classification">
    Enums, confidence scores, and grounded evidence.
  </Card>

  <Card title="Data extraction" icon="map" href="/json-schema/data-extraction">
    Pull structured fields from invoices, receipts, and documents.
  </Card>

  <Card title="Form processing" icon="map" href="/json-schema/form-processing">
    Normalize messy user input into typed backend payloads.
  </Card>

  <Card title="API call generation" icon="map" href="/json-schema/api-calls">
    Map natural language to execution-ready API requests.
  </Card>

  <Card title="UI generation" icon="map" href="/json-schema/ui-generation">
    Generate renderable form specs from product requirements.
  </Card>

  <Card title="Content generation" icon="map" href="/json-schema/content-generation">
    Structured marketing copy with length bounds and tone control.
  </Card>
</Columns>

## Reference

<Columns cols={2}>
  <Card title="Data types" icon="code" href="/json-schema/reference/string">
    String, number, integer, boolean, null, const, object, array.
  </Card>

  <Card title="Schema composition" icon="code" href="/json-schema/reference/composition">
    Combine and reuse schemas with `allOf`, `anyOf`, `oneOf`, `not`, `$ref`, and `$defs`.
  </Card>

  <Card title="Conditional logic" icon="code" href="/json-schema/reference/conditionals">
    Model context-dependent requirements with `if`/`then`/`else` and dependent keywords.
  </Card>
</Columns>

Core type references: [String](/json-schema/reference/string), [Number](/json-schema/reference/number), [Integer](/json-schema/reference/integer), [Boolean](/json-schema/reference/boolean), [Null](/json-schema/reference/null), [Const](/json-schema/reference/const), [Object](/json-schema/reference/object), [Array](/json-schema/reference/array).
