EXPLAINER

JSON Schema

standardfreshness: volatilesources not yet verified

JSON Schema is a vocabulary for describing and validating the shape of JSON data. It underpins tool definitions, structured outputs and API contracts for AI applications.

Short answer: JSON Schema describes what valid JSON looks like: types, required fields, enums, ranges. AI tool definitions and structured outputs commonly use a subset of it; providers vary in which keywords they support.

What is it?

JSON Schema is a standard way to write down the shape of JSON data — "this has a string called name, an integer age between 0 and 120, and an optional email". It lets software check data automatically.

In AI work it appears in function-calling tool definitions and in structured-output features.

Also known as: jsonschema, json schema validation, schema for tool parameters, tool schema, input_schema, parameters schema.

Technical definition

JSON Schema is a declarative specification (published as versioned drafts/dialects such as 2020-12) with keywords such as type, properties, required, enum, items, minimum, pattern and oneOf/anyOf. Validators exist for most languages. LLM providers and constrained-decoding engines typically support restricted subsets and may reject or ignore unsupported keywords, so schemas should be tested against the target.

Entity type: standard · Freshness class: volatile.

When should I use it?

Use whenever tools or outputs cross a code boundary.

Implementation patterns

  • One schema as the contract for prompt, enforcement and validation.
  • Generate schemas from typed models.
  • Use enums and descriptions to guide the model.
  • Keep schemas shallow and simple for LLM use.

Technologies and frameworks

Commonly associated: Ajv, Python jsonschema, Pydantic, Zod (schema export). Names are examples of what exists, not recommendations, and projects change quickly.

Practical guide

  1. Model the data with typed classes or Zod.
  2. Export JSON Schema.
  3. Add field descriptions and enums.
  4. Test against the target provider/engine.
  5. Validate outputs with a full validator.

Common failure modes

  • Using keywords the provider ignores or rejects.
  • Deeply nested or recursive schemas hitting limits.
  • Missing descriptions, leaving the model to guess meaning.
  • Schema drift between prompt text and validator.

Troubleshooting

  • Provider errors on schema — Remove unsupported keywords; check current docs.
  • Model fills fields incorrectly — Add descriptions and enums; simplify.
  • Validator and provider disagree — Treat provider acceptance and your validator as separate checks.

Contrasted with

Questions this page answers

  • What is JSON Schema?
  • How do I write a JSON Schema for function calling?
  • Which JSON Schema features do LLM APIs support?
  • How do I validate JSON against a schema?

Typical goals: write a schema for tool arguments; validate model JSON; find which keywords providers support.

Sources and verification

Status: not independently verified. This entry was authored on 2026-10-06 from general technical knowledge, without live checking of the sources below. Treat every source as a lead to confirm (identifier, title, authorship, current version) before publication or citation.

Freshness class: volatile — Products, versions, protocols, benchmarks, leaderboards, regulations and dates. Verify against the primary source before relying on specifics; re-review every 3 months.

Time-sensitive claims to verify before relying on them:

  • Current JSON Schema draft/dialect numbering.
  • Which keywords each AI provider supports.

Canonical sources (unverified leads):

  • JSON Schema specification and dialect list — json-schema.org
Learning path: Structured output and constrained decoding (step 3 of 6)