JSON Schema Basics

An introduction to JSON Schema for validating structure, types, and required fields.

Interactive Tool: Practice in real-time with Pixlint's free browser-based Validate JSON Structure. No data is uploaded.
Open tool →

JSON Schema is a declarative language for validating the structure, constraint requirements, and data types of JSON documents. It acts as a contract between API producers and consumers.

A Simple JSON Schema Example

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "username": { "type": "string", "minLength": 3 },
    "email": { "type": "string", "format": "email" },
    "role": { "type": "string", "enum": ["admin", "editor", "user"] }
  },
  "required": ["id", "username", "email"]
}