Skip to content

Intermediate · JSON Schema — Structure Your Data

All tutorials

JSON Schema — Structure Your Data

JSON Schema is a vocabulary for annotating and validating JSON documents. It defines allowed types, required properties, formats (email, date), and custom rules. Tools like Ajv (JavaScript) and jsonschema (Python) validate data against schemas.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "age": {"type": "number", "minimum": 0},
    "email": {"type": "string", "format": "email"}
  },
  "required": ["name", "email"]
}