JSON Schema Validation - Validate JSON Structure
What is JSON Schema?
JSON Schema is a vocabulary for annotating and validating JSON documents. It lets you define the expected structure, types, and constraints for your data — then automatically check whether a JSON document conforms to those rules. It's widely used for API validation, configuration files, and data interchange formats.
Basic Schema Structure
A JSON Schema is itself a JSON object. The simplest schema specifies a type:
{ "type": "string" } | Value must be a string |
{ "type": "number" } | Value must be a number |
{ "type": "boolean" } | Value must be true or false |
{ "type": "object" } | Value must be an object |
{ "type": "array" } | Value must be an array |
{ "type": "null" } | Value must be null |
Object Validation
Objects are the most common type to validate. Key keywords:
properties | Define schemas for specific keys |
required | Array of keys that must be present |
additionalProperties | Whether extra keys are allowed (default: true) |
minProperties / maxProperties | Limit the number of keys |
Example: { "type": "object", "required": ["name"], "properties": { "name": { "type": "string" } } }
Array Validation
items | Schema that every element must match |
minItems / maxItems | Limit the number of elements |
uniqueItems | All elements must be distinct |
Example: { "type": "array", "items": { "type": "string" }, "minItems": 1 } — a non-empty array of strings.
String & Number Constraints
minLength / maxLength | String length limits |
pattern | Regex pattern the string must match |
format | Semantic format: date, email, uri, ipv4, etc. |
minimum / maximum | Number range limits |
enum | Value must be one of the listed options |
Formats like date, email, and uri are fully validated — an invalid email address will be flagged as an error.
Using Schema Validation
In the JSON Workbench, the schema validator appears as a collapsible card above the output area whenever you have valid JSON loaded:
- Load sample — Click to load a sample schema that demonstrates common validation rules.
- Paste your own — Expand the card and paste any JSON Schema into the textarea.
- Live validation — Errors update instantly as you edit either the JSON or the schema.
- Click errors — Click any error path to jump to that location in the tree viewer.
- Persistent — Your schema is saved to localStorage and restored on reload.