Validate JSON against a JSON Schema (draft 2020-12, or draft-07 through $schema) and see each error with the path where it occurs.
What is JSON Schema Validator?
JSON Schema Validator is a free online tool that checks a JSON document against a JSON Schema, in your browser, and lists every place where the document breaks the schema, each with its location and the keyword that failed. It follows draft 2020-12 unless the schema names another draft in $schema.
Use it to test a schema, or to find out why an API payload or a configuration file is rejected.
What it supports
- A schema (an object, or true or false) and a JSON document, both as text. Validation follows JSON Schema draft 2020-12 unless $schema says otherwise.
- Drafts: $schema selects draft-04, draft-06, draft-07, 2019-09 or 2020-12, with http or https and with or without a final #. Draft-06 is checked with the draft-07 rules, because the tool has no separate draft-06 mode and draft-07 only adds keywords to it. Any other $schema is refused.
- Every error is collected, not only the first. Each one is a line with the location of the value in your JSON as a JSON Pointer after # (# is the whole document, #/items/1/qty is a nested value), the keyword that failed in parentheses and an explanation.
- Errors that repeat each other are listed once, and the lines that only restate a deeper error are left out. If there are more than 100 errors, the first 100 are listed and the result says how many more were omitted.
- A $ref that points inside the same schema, such as #/$defs/name, is followed. A $ref to another document is never fetched: it is refused as an invalid schema.
- A schema that is just true accepts every document, and false rejects every one.
Good to know
- The tool only validates. It never changes your JSON, fills in default values or converts types.
- The location and the keyword are the parts to rely on. The explanation after them is a plain-language summary written in the language of the page.
- Before validating, the tool refuses a schema, names it as the schema and points at the keyword, when a type is not one of the JSON types (array, boolean, integer, null, number, object or string), when a $ref points nowhere or to another document, or when a pattern or a patternProperties name is not a valid regular expression. A $ref that loops back on itself is stopped as a processing limit.
- The tool does not check a schema against its meta-schema. Any other keyword with the wrong shape (such as required: 5) is noticed only when the JSON being checked reaches it, so a mistake there can go unnoticed.
- A name repeated inside one object, in the schema or in the JSON, and a string with an unpaired surrogate escape are refused instead of letting one value win.
- For validation, numbers are read as the double-precision numbers that most programs use, so a number with more digits than that is compared by its rounded value.
How do I use JSON Schema Validator?
- Paste or type your schema in “JSON Schema” and the JSON to check in “JSON”. Nothing runs while you type.
- Press “Validate”.
- Read the result next to your inputs. If the JSON follows the schema, the result says so. If not, each error is one line: the location in your JSON, the keyword that failed in parentheses and an explanation. If an input cannot be used, the message names it and gives the line and column.
- When there are errors, press “Copy” to put them on your clipboard, or “Download” to save them as errors.txt.
Examples
JSON that follows the schema
Put the schema in “JSON Schema”, this JSON in “JSON” and press “Validate”. Every rule is met, so the result says the JSON follows the schema.
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 }
},
"required": ["name"]
}{"name": "Ada", "age": 36}The JSON is valid against the schema.
Errors with their locations
The name that the schema requires is missing, which is reported at # (the whole document), and age is below its minimum of 0, which is reported at #/age. All errors are listed together, not only the first.
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 }
},
"required": ["name"]
}{"age": -3}The JSON does not match the schema.
# (required): Instance does not have required property "name".
#/age (minimum): -3 is less than 0.A wrong type, and an extra property
age is a text, but the schema asks for an integer. The extra property is not an error, because this schema does not set additionalProperties to false: a schema allows whatever it does not forbid.
{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 }
},
"required": ["name"]
}{"name": "Ada", "age": "x", "extra": 1}The JSON does not match the schema.
#/age (type): Instance type "string" is invalid. Expected "integer".A schema the tool cannot use
The tool supports draft-04, draft-06, draft-07, 2019-09 and 2020-12. An unknown $schema is refused, instead of validating under rules that may not be the ones you meant. The message points at the schema input.
{"$schema": "https://example.com/meta"}{}The schema declares a $schema this tool does not support. It supports JSON Schema draft-04, draft-06, draft-07, 2019-09 and 2020-12. Remove $schema to use 2020-12.
Limits and privacy
Size limits
- Input: each box takes up to 2,000,000 bytes of UTF-8 text (about 2 MB), counted separately. Accented letters and emoji take more than one byte each. Larger input is rejected.
- Nesting: up to 256 levels of objects and lists inside each other. Deeper JSON is refused because it is beyond what the tool processes.
- Time: a run that takes longer than its time limit is stopped. Try a smaller input.
Is my text sent to a server?
No. The text you type or paste, or open from a local file, is processed locally in your browser, in a dedicated Web Worker. It is never uploaded or sent to the server (a file you open is read in your browser only), and it is not written to storage, cookies or the address bar.
“Copy” puts the result on your clipboard and “Download” saves it as a file, but only when you press the button. The file is created in your browser, so nothing is uploaded.
For the full details, see the Privacy Policy
Related tools and pages
Your text stays in the page when you switch tools in the same tab, so you can try the same text in another tool. Reloading or closing the tab ends it.