JSON Schema
JSON Schema is a vocabulary, written in JSON, for describing the structure, types and constraints a JSON document must follow. A validator checks a document against the schema and reports every mismatch. Teams use it to validate API payloads and config files, generate forms and write documentation.
In more detail
JSON Schema is a vocabulary, written in JSON itself, for describing what valid JSON data looks like. A schema lists the expected types, required properties, allowed values and limits, and a validator checks a document against it and reports every mismatch.
The core keywords are type, properties, required, items, enum and const, plus limits such as minimum, maxLength and pattern. $ref reuses a definition, and oneOf, anyOf and allOf combine schemas.
The specification has several drafts. Draft 2020-12 is the current one and is what OpenAPI 3.1 uses. The $schema keyword at the top says which draft a schema follows.
Teams use JSON Schema to validate API requests and config files, generate types and forms, and document data formats. You can generate a first schema from a sample document and tighten it by hand.
Example
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["id", "email"],
"properties": {
"id": { "type": "integer", "minimum": 1 },
"email": { "type": "string", "format": "email" },
"role": { "enum": ["admin", "editor", "viewer"] }
}
}Try it
Learn more in the guide JSON Schema: a complete guide with examples.
← Back to JSON Schema in the JSON glossaryUpdated 2026-10-01