How to Validate JSON Against a Schema
Step-by-step guide to writing a JSON Schema and validating your JSON documents to catch data errors before they reach production.
Tool Used
JSON Schema Validator
Write your JSON Schema
Open the JSON Schema Validator tool. In the left (Schema) panel, write a schema that describes your expected data. Start with the type, required fields, and property constraints. For example: { "type": "object", "required": ["id", "email"], "properties": { "id": { "type": "integer" }, "email": { "type": "string", "format": "email" } } }. Add the $schema property at the top to declare the draft version you are using.
Paste your JSON document
In the right (JSON) panel, paste the JSON document you want to validate. This can be an API response, a configuration file, a seed data fixture, or any JSON you want to check against the schema. Make sure the JSON is well-formed — the validator will report parse errors separately from schema validation errors.
Click Validate and read the results
Click the Validate button. If the document matches the schema, you see a green success message. If there are violations, each error shows the JSON Pointer path to the failing field (e.g., /email), the keyword that failed (e.g., format), and a human-readable message. Fix the schema or the document and validate again until all errors are resolved.
Add more constraints
Refine your schema with additional constraints: use minLength and maxLength for strings, minimum and maximum for numbers, enum for allowed values, and pattern for regex validation. For arrays, set minItems and use the items keyword to define a schema for each element. For objects, use additionalProperties: false to reject extra fields not listed in properties.
Use $defs for reusable sub-schemas
If multiple properties share the same shape, define the sub-schema once in $defs and reference it with $ref. For example: { "$defs": { "address": { "type": "object", "required": ["street", "city"] } }, "properties": { "billing": { "$ref": "#/$defs/address" }, "shipping": { "$ref": "#/$defs/address" } } }. This keeps your schema DRY and makes it easier to update shared definitions.
All done!
You are ready to use JSON Schema Validator like a pro.