JSON Schema Tutorial
6 interactive lessons — paste real JSON, see live validation errors. Learn JSON Schema from scratch: types, string and number constraints, arrays, combining schemas, and building a full real-world API schema with $defs and $ref.
What Is JSON Schema?
JSON Schema is a vocabulary — itself expressed as JSON — for describing the structure, types, and constraints that another JSON document must satisfy. Instead of writing ad-hoc validation code ("check that age is a number, check that emaillooks like an email"), you declare those rules once, as data, and any JSON Schema-aware validator can enforce them consistently across your frontend, backend, and CI pipeline.
It shows up throughout the modern API ecosystem: OpenAPI embeds JSON Schema to describe request and response bodies, tools like Ajv and this site's own JSON Schema Validator use it to validate real payloads, and code generators use it to produce TypeScript interfaces, form UIs, and API client SDKs from a single source of truth. The specification has evolved through several drafts (04, 06, 07, 2019-09, 2020-12); this tutorial uses Draft 2020-12, the current stable version, throughout.
Unlike reading the spec top to bottom, every lesson here is a live playground: the schema and the data are both editable, and validation re-runs on every keystroke, so you see immediately which rule caught which mistake — the fastest way to build an intuition for how a validator actually reads a schema.
Your First Schema
Define structure, types, and required fields with JSON Schema
String Validation
Constrain strings with length, pattern, format, and enum
Numbers & Ranges
Validate numeric bounds, divisibility, and integer types
Arrays & Items
Validate array elements, length, and uniqueness
Combining Schemas
Use allOf, anyOf, oneOf, and if/then/else for conditionals
Real-World Schema
Compose complex schemas with $defs, $ref, and nested objects
Frequently Asked Questions
Ready to validate your own schemas?
Use these tools to validate and generate JSON Schemas for your real projects.