What is JSON Schema?
Short answer
JSON Schema is itself JSON that describes what valid JSON should look like: which fields are required, what type each value must be, and what constraints apply. Validators use it to check data automatically.
A description of valid data
Instead of checking data by hand, you write a schema that states the rules, then let a validator confirm any document follows them. The schema is written in JSON, so the same tooling reads both the data and its description.
{
"type": "object",
"required": ["id", "name"],
"properties": {
"id": { "type": "integer" },
"name": { "type": "string", "minLength": 1 }
}
}What it can express
- The type of each value: object, array, string, number, boolean, or null
- Which properties are required
- Constraints like minimum, maximum, length, and patterns
- Enumerated allowed values and nested object shapes