Free JSON Schema Validator
Validate JSON against supported schema drafts with exact error locations and local references.
Loading tool…
How to validate JSON against a schema locally
JSON syntax validation only checks whether data can be parsed. Schema validation adds checks for required fields, types, ranges and other supported constraints.
- Paste JSON data or import a JSON file.
- Paste the schema and select its matching schema draft.
- Choose whether to report all errors and run validation.
- Read instance and keyword locations, fix the data or schema and download the result.
Who gets the most out of schema checks
Schema validation helps anyone who receives JSON from another system and needs to know it has the right shape before using it. A backend developer can test a sample API payload against the contract a partner team published. A QA tester can confirm that a fixture file still matches the schema after a field was renamed.
It is also useful for configuration files. Many tools describe their settings with a JSON Schema, so you can paste your config and the schema side by side and catch a misspelled key or a wrong value type before a deploy fails. Data teams use the same idea to spot bad records in an export before loading them.
A worked example with the built-in sample
Select Load example. The schema requires name and email, limits name to at least 2 characters, expects email to match the email format, expects age to be an integer of at least 18, and sets additionalProperties to false. The sample data, with name Sam, email sam@example.com and age 23, returns valid: true with an empty errors list.
Now change the data to name Sam, age 16 and an extra role of admin, and remove email. With Report all validation errors turned on, the report lists a required error at instance location # for the missing email property, a minimum error at #/age with the message 16 is less than 18, and an additionalProperties error at #/role for the property that is not allowed.
You may also see a follow-on additionalProperties entry for age, because a property that fails its own rule is not counted as successfully evaluated. Fix the minimum problem and that extra entry disappears.
How to read the validation report
The result is a small JSON report. The valid field is true or false. Each error carries four parts: instanceLocation points to the spot in your data, keywordLocation points to the rule in the schema, keyword names the rule that failed, and error gives a plain message. The # symbol stands for the root of the document, and each slash adds one level, such as #/address/zip.
When the report all errors option is off, validation stops at the first failure. That is faster for a quick yes or no answer. Leave it on when you want a full list of fixes in one pass. You can copy or download the report as a JSON file to attach to a ticket or a code review.
Common mistakes to avoid
Picking the wrong draft is the most frequent problem. Keywords such as $defs, prefixItems and unevaluatedProperties belong to newer drafts, while definitions and the array form of items come from older ones. Match the draft menu to the $schema line at the top of your schema.
Another mistake is pointing $ref at a web address. Only references that start with # are accepted, so move shared definitions into $defs inside the same schema. Finally, remember the limits: input up to 2 MB, at most 80,000 nodes and 60 levels of nesting. Split very large files into smaller samples before you test them.
Useful tips and limitations
- Keep references inside the supplied schema; external references are disabled.
- Choose the correct draft and review unsupported keywords before relying on a schema check.
- Keep a small set of known good and known bad sample files next to each schema so you can recheck both after every schema edit.
- Read the keywordLocation path first, because it tells you whether the data is wrong or the rule itself is stricter than you intended.
Common questions
Which JSON Schema drafts can I select?
The tool offers drafts 4, 7, 2019-09 and 2020-12 using a local validator. Not every optional vocabulary is supported.
Does schema validation change my JSON values?
No. The tool reports validation results without coercing values, filling defaults or rewriting your input.
What does the # symbol mean in an error location?
It marks the root of the JSON document. Each segment after a slash is a property name or array index, so #/items/0/price points to the price of the first item.
Can the schema itself be a boolean?
Yes. The validator accepts an object schema or a boolean schema. A schema of true accepts any value and a schema of false rejects every value.
Why did I get only one error when my data has several problems?
The Report all validation errors option is probably turned off. In that mode validation stops at the first failure, so turn it back on to list every problem in one run.
JSON and schemas run in a local worker. No remote schemas or input data are fetched or uploaded.
