JSON Schema Type Reference

All JSON Schema types and keywords with examples.

Searchable reference of JSON Schema draft-07 and 2020-12 instance types and validation keywords — type, enum, properties, items, allOf, if/then and $ref — each with an example.

What instance types does JSON Schema define?

JSON Schema validates against the JSON data model: string, number, integer, boolean, object, array and null. The type keyword restricts an instance to one or more of these. Type-specific keywords such as minItems or properties only take effect when the instance is the matching type.

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: false to catch typos in property names during validation.
  • In 2020-12 use prefixItems for tuples and items for the remaining elements; in draft-07 a items array did the positional job.
  • $ref plus $defs keeps large schemas DRY by referencing reusable subschemas.
  • format is an annotation unless your validator enables format assertion — pair it with pattern when you need a hard guarantee.