JSON Schema keywords (2020-12)
JSON Schema is a vocabulary for validating and annotating JSON documents. The 2020-12 draft organizes its keywords into vocabularies: core, validation, applicators, and annotations. This reference lists the keywords developers reach for most, with the JSON types each applies to and the exact assertion it makes.
How it works
Evaluation walks the schema against an instance. A validation keyword directly asserts a constraint — minimum checks a number, pattern matches a string against a regex, required lists mandatory object members. These produce a pass/fail boolean.
An applicator keyword does not assert anything itself; it applies subschemas to parts of the instance. properties maps names to subschemas, items applies a schema to array elements, and allOf/anyOf/oneOf combine subschemas logically. The instance is valid only if the delegated subschemas validate.
Core keywords structure the document: $id sets the base URI, $ref/$dynamicRef reference other schemas, and $defs holds reusable subschemas. A key 2020-12 change is that $ref may now coexist with sibling keywords rather than replacing them.
Annotation keywords (title, description, default, examples, deprecated, readOnly) attach metadata without affecting validity, and are gathered as annotations for tooling.
Tips and example
A schema mixing several keyword groups:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"age": { "type": "integer", "minimum": 0 },
"tags": { "type": "array", "items": { "type": "string" } }
},
"required": ["age"],
"additionalProperties": false
}
Remember that additionalProperties: false only sees properties not matched by properties or patternProperties — a frequent source of confusion. Filter the table below by group to confirm what any keyword applies to before relying on it.