Developer and Text Tools

How to Validate JSON Against a JSON Schema and Read the Errors

A practical guide to JSON Schema: drafts, the most used keywords, reading error paths, batch checks of exports and a first schema built from sample data.

Saizul Amin
Saizul Amin3 Nov 2026 · 3 min read
How to Validate JSON Against a JSON Schema and Read the Errors

A JSON Schema is a contract. It says which properties a document must have, what types they are and which values are allowed. APIs use it to reject bad requests, editors use it for autocomplete in configuration files, and data teams use it to catch broken records before they reach a warehouse. This guide covers the essentials and shows how to find out exactly why a document fails.

The keywords you will use most

  • type limits a value to string, number, integer, boolean, object, array or null.
  • required lists properties that must be present.
  • properties gives a schema for each named property, and additionalProperties: false forbids anything else.
  • enum and const restrict a value to a fixed list or one value.
  • minimum, maximum, minLength, maxLength and pattern set ranges and formats.
  • items describes array elements; uniqueItems forbids duplicates.
  • $ref reuses a definition, usually from $defs.
  • anyOf, oneOf, allOf, not and if/then/else combine rules.

Drafts matter

JSON Schema has several published versions. Draft 7 is still very common, and 2020-12 is the current one. They differ in details: 2020-12 uses prefixItems for tuples where draft 7 used an array in items, and in draft 7 a $ref makes the validator ignore keywords next to it. The $schema line at the top tells a validator which rules to apply, so keep it in your schemas.

Reading an error

A useful error has three parts. The instance path, such as /address/country, says where in your data the problem is. The keyword, such as pattern, says which rule failed. The schema path, such as #/$defs/address/properties/country/pattern, says where that rule lives in the schema. With all three you can decide quickly whether the data or the schema is wrong.

Errors from anyOf and oneOf are the hardest to read, because the data failed several alternatives at once. A good validator reports the combination failure and the errors of the closest alternative.

Validating with the tool

The JSON Schema Validator runs in your browser.

  1. Paste the schema, or tap Sample to see a realistic one with $defs, if/then and formats.
  2. Paste the data: one document, an array of records or JSON Lines.
  3. Leave the draft on automatic, or force one. Choose whether to validate the whole input or each item.
  4. Read the results. Every document shows a tick or the full list of errors with paths and keywords.
  5. Edit and watch the results update. Undo is there if an edit goes wrong.
  6. Download the errors as CSV for a ticket, or the full report as JSON.

Checking an export in one go

Batch mode is where a validator earns its keep. Paste a JSON array or a JSON Lines dump and each record is validated separately and labelled by its index or line number. The summary tells you how many records are invalid and how many errors there are in total, so you can tell at a glance whether one record is broken or the whole feed changed shape.

Starting a schema from data

Writing a schema from scratch is slow. Schema from data infers one from your sample: types, nested objects, array items, formats such as date or email, and the properties present in every record as required. Treat it as a first draft. Tighten it with enums, ranges and patterns that reflect real business rules, and decide deliberately whether extra properties are allowed.

Limits worth knowing

References to other files or URLs are not downloaded; copy those definitions into $defs. Format checks test syntax only, so a well-formed email address may still not exist. Specialised vocabularies and content keywords are not evaluated.

Summary

Keep $schema in every schema, read errors by instance path first, validate exports record by record, and grow a schema from real samples. A few minutes of validation saves hours of tracing a bad record through a pipeline.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages