Every JSON Schema keyword, grouped by what it constrains
JSON Schema describes the shape of JSON data using a vocabulary of keywords. This reference lists the instance types and the validation keywords that apply to each — string, numeric, object, array and the boolean combinators — for the draft-07 and 2020-12 drafts, with a short example for every entry.
How it works
A JSON Schema is itself a JSON object. The type keyword pins the instance to
one of the seven JSON types, and type-specific keywords then add constraints.
Keywords that do not match the instance type are simply ignored, which is why a
schema can combine, say, string and array constraints safely.
{
"type": "object",
"required": ["id", "tags"],
"properties": {
"id": { "type": "integer", "minimum": 1 },
"tags": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }
},
"additionalProperties": false
}
Boolean combinators — allOf, anyOf, oneOf and not — let you compose
subschemas, and if/then/else applies them conditionally.
Tips and notes
- Prefer
additionalProperties: falseto catch typos in property names during validation. - In 2020-12 use
prefixItemsfor tuples anditemsfor the remaining elements; in draft-07 aitemsarray did the positional job. $refplus$defskeeps large schemas DRY by referencing reusable subschemas.formatis an annotation unless your validator enables format assertion — pair it withpatternwhen you need a hard guarantee.