JSON Schema Validator
Operator: Abdulla Al Fahad. How tools are built and checked
A model was asked for JSON that follows a schema, a partner sent a webhook payload, or a config file was edited by hand, and now the question is simple: does this data fit the schema, and if not, where exactly does it go wrong? This validator answers both parts. It lists every error, not only the first, each with the path to the offending value, the place in the schema whose rule failed, and a sentence saying what was expected.
It is also honest about its own reach. JSON Schema has more keywords than any small validator covers, and a validator that skips a keyword it does not understand will happily report a pass. Here every keyword that was not checked, every reference that points outside the schema and every rule with a malformed value is listed under Not checked, so a green result means the data passed every rule that was actually applied, and an amber one tells you which rules were left out.
Key features
- Every error listed, up to 1,000, with the value's JSON Pointer, the failing keyword's schema path and a plain message
- A Not checked list for unsupported keywords, remote or anchor $ref values and keywords with malformed values
- Local $ref resolution with JSON Pointer escapes, percent-encoding and recursive schemas, with loops detected
- anyOf and oneOf failures explained with the first problem found in each alternative
- Format checks for date-time, date, email, uri and uuid that can be switched off
- JSON Lines mode for checking a batch of model outputs or log records line by line
- multipleOf compared in decimal, so 19.99 is a multiple of 0.01
- Copy report button that puts the summary, errors and Not checked list on the clipboard as plain text
Which draft 2020-12 keywords are checked
There are two boxes: the schema and the data, each pasted or loaded from a file of up to 2 MB. The schema must be a JSON object, or true or false, the two boolean schemas the standard allows. The data can be one JSON document, or, with Data is JSON Lines ticked, a file with one JSON value per line, where each non-blank line is checked on its own. Files must be UTF-8, or UTF-16 with a byte-order mark; archives, PDFs and other binary files are refused.
Keywords are applied with their draft 2020-12 meaning, with the common draft-07 forms also understood: definitions next to $defs, and items written as an array (a tuple) together with additionalItems. The checked set is type (a single type or a list), enum, const, properties, required, additionalProperties, patternProperties, items, prefixItems, additionalItems, minItems, maxItems, uniqueItems, minLength, maxLength, pattern, format, minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, allOf, anyOf, oneOf, not, if, then and else, plus $ref to a JSON Pointer inside the same schema, such as #, #/$defs/address or #/definitions/address.
pattern and patternProperties are compiled as JavaScript regular expressions with the u flag and match anywhere in the string unless the pattern has ^ and $. format is checked for date-time, date, email, uri and uuid when Check formats is ticked, which it is by default. Titles, descriptions, defaults, examples, $comment and similar labels do not constrain data and are ignored without a note.
How it works
Both boxes are parsed with the browser's JSON.parse. A syntax error in either one stops there and is reported with its line and column, using the same position finder as the JSON formatter on this site. A schema that parses but is an array, a string or a number is refused, since only objects and true or false can be schemas.
Before any data is looked at, the whole schema is walked once. Every keyword is sorted into checked, label-only or not checked, every $ref is resolved, and every value is checked for the right shape: a minLength of "5" or a required list that is a plain string is recorded as malformed and skipped rather than half-applied. Regular expressions are compiled at this stage, and one that the browser cannot compile with the u flag is listed with the browser's own message.
The data is then checked against the schema from the root down. Each failing rule adds an error with two paths: the JSON Pointer of the value, such as /items/2/qty, and the location of the keyword in the schema, such as #/properties/items/items/properties/qty/minimum. When a $ref is followed, the schema path switches to where the referenced schema lives, so it points at the rule you would actually edit. For anyOf and oneOf the alternatives are first tried quietly; only when none fits is an error added, carrying the first problem found in each of up to five alternatives.
Changing Check formats or Data is JSON Lines re-runs the check on the text already submitted; editing either box clears the result until you press Validate again.
When to run it
- Checking that a model's structured reply matches the schema you sent before your code reads it
- Running a JSON Lines file of batch outputs or extracted records and finding the lines that broke the contract
- Testing a webhook payload from a partner against the schema in their documentation
- Confirming that a schema written by hand, or by the JSON Schema Generator on this site, accepts the records it should and rejects the ones it should not
- Finding which field in a hand-edited config file breaks the schema an application loads it with
Running a check
- Paste the schema into the left box, or press Choose file and open the .json file that holds it.
- Paste the data into the right box. For a batch of records, one per line, tick Data is JSON Lines.
- Leave Check formats on unless your schema uses format only as documentation.
- Press Validate and read the banner: green for a full pass, amber for a pass with rules that were not checked, red with the error count.
- Work down the errors table. Value path tells you where the problem is in the data; Schema path tells you which rule rejected it.
- Read the Not checked list before trusting a pass, then press Copy report if you need to share the result.
Example
An invoice line checked against a four-field schema
Schema:
{"type": "object",
"required": ["sku", "quantity", "unit_price", "currency"],
"properties": {
"sku": {"type": "string", "pattern": "^[A-Z]{3}-[0-9]{4}$"},
"quantity": {"type": "integer", "minimum": 1},
"unit_price": {"type": "number", "multipleOf": 0.01},
"currency": {"enum": ["EUR", "GBP", "USD"]}},
"additionalProperties": false}
Data:
{"sku": "lmp-0042", "quantity": 2.5,
"unit_price": 19.999, "currency": "usd"}Result: Invalid, 4 errors
/sku #/properties/sku/pattern
String "lmp-0042" does not match the pattern
^[A-Z]{3}-[0-9]{4}$.
/quantity #/properties/quantity/type
Expected integer but found number 2.5.
/unit_price #/properties/unit_price/multipleOf
19.999 is not a multiple of 0.01.
/currency #/properties/currency/enum
String "usd" is not one of the allowed values:
"EUR", "GBP", "USD".
(Corrected to "LMP-0042", 2, 19.99 and "USD",
the same line passes.)Tips for best results
- When an anyOf error appears, read its option lines: they usually show that one alternative failed on a single field, which is the field to fix.
- Test a schema with data that should fail as well as data that should pass. A schema that accepts everything will never show an error.
- If a field holds an extra property your schema does not list, the error sits on the property itself, such as /room, not on the object that contains it.
- Paste a model's output exactly as it arrived. If it is wrapped in a code fence or has text before the brace, the data box reports a syntax error, which is also worth knowing before your own code parses it.
- For JSON Lines, the line numbers count every line of the box, blank ones included, so they match the line numbers in your editor.
Limits
A pass is only as complete as the Not checked list is empty. contains, propertyNames, minProperties, maxProperties, dependentRequired, dependentSchemas and the unevaluated keywords are listed there rather than checked.
Remote references are not fetched. A $ref to another file or a URL is listed as not checked and the value it would have described is not tested.
JSON.parse rounds integers above 9,007,199,254,740,991, so a minimum, maximum or enum comparison on such a number uses the rounded value.
Patterns written for other regex engines can fail to compile with the u flag; \- outside a character class and inline flags such as (?i) are common examples.
1.0 counts as an integer, because the standard treats any number with no fractional part as one and JSON.parse reads 1.0 as 1.
Common errors and how to fix them
- "The schema is not valid JSON: line 12, column 5"
- The schema box failed to parse before any checking started. Go to that line; a trailing comma, a comment or a single-quoted key are the usual culprits, and the explanation under the heading names what was found.
- "A JSON Schema must be an object (or true or false), but this input is an array."
- The data and the schema may have been pasted into the wrong boxes, or the file holds a list of schemas. Paste the schema object itself, which starts with {.
- The data is reported as more than one JSON value
- The data box holds several records one after another. If each line is its own record, tick Data is JSON Lines; otherwise wrap the records in [ ] with commas between them and give the schema an array type.
- "... names an anchor; only JSON Pointer references such as #/$defs/name are followed"
- The schema refers to a subschema by its $anchor name. Change the reference to the pointer form, for example from #address to #/$defs/address, and validate again.
- "exclusiveMinimum is written as true or false, the draft-04 form"
- Draft-04 schemas pair "minimum": 0 with "exclusiveMinimum": true. In later drafts the bound itself goes in exclusiveMinimum, so write "exclusiveMinimum": 0 and remove the minimum.
- "This line is not valid JSON" on one line of a JSON Lines file
- That line holds a broken record, often one that was cut off or pretty-printed across several lines. JSON Lines needs each record on a single line; the other lines are still checked.
Best practices
- Keep Check formats on when validating data for an API; format is where dates like 2026-02-30 slip through.
- Rewrite or remove keywords that land in Not checked if this validator is part of your review process, so a pass means a full pass.
- Validate a sample of real model outputs whenever the schema changes, not only the example record you wrote it from.
- Point $ref values at $defs inside the same file instead of at URLs when the schema has to be checked in more than one tool.
Reading the two paths
The value path is a JSON Pointer into the data. /items/2/qty means the qty property of the third element of items, because array positions count from 0. (root) stands for the whole document, which is where a missing required property is reported: {} checked against a schema that requires id gives one error at (root) saying the id property is missing. A slash inside a key is written ~1 and a tilde is written ~0, so the key a/b appears as /a~1b.
The schema path is the location of the rule that failed, written as a pointer into the schema with # in front. #/properties/id/type means the type keyword inside the id property's schema. When the failing rule sits in a definition reached through $ref, the path starts at the definition, such as #/$defs/guest/required, which is the place to edit.
What Not checked means
JSON Schema says that a validator should ignore keywords it does not know, which makes sense for labels but is risky for rules. If a schema relies on minProperties and the validator ignores it, data with an empty object passes without comment. This tool lists each such keyword with its schema path and a reason: a keyword it does not support, an unknown keyword, a format it does not check, a reference it will not fetch, a reference that resolves to nothing, or a value of the wrong shape.
When the data has errors as well, both lists are shown. When it has none, the banner turns amber instead of green and says how many parts of the schema were not checked, because the honest verdict is a partial pass.
Draft-07 and older schemas
Many schemas in the wild still declare draft-07 and keep their subschemas under definitions; both work here. Two differences matter. In draft-07 every keyword placed next to $ref is ignored, while 2020-12 applies them, and this validator follows 2020-12, so a type sitting beside a $ref is checked. And draft-04's boolean exclusiveMinimum and exclusiveMaximum are listed as malformed rather than guessed at. When a schema declares an older draft, a note under the result banner says so.
Privacy and limits
The schema and the data are parsed and checked by JavaScript in the open tab. Neither is uploaded, and the tool writes nothing to localStorage, sessionStorage or IndexedDB. Each box takes up to 2 MB. Errors past the first 1,000 are counted in the banner but not listed, and checking stops after 800 nested steps through a recursive schema, with a Not checked note at the place where it stopped.
Frequently asked questions
Is format checked by default?
Yes, for date-time, date, email, uri and uuid. Draft 2020-12 treats format as a label unless a validator chooses to check it, so another validator may pass data that fails here. Untick Check formats to match that behaviour; every format keyword is then listed under Not checked.
Why does my regular expression work in Python but not here?
Patterns are compiled as JavaScript regular expressions with the u flag, which is stricter about escapes and has no inline flags like (?i). The Not checked list shows the browser's own compile message for any pattern it could not use.
Can it validate the schema itself against the meta-schema?
Not in full. It checks the shape of each keyword it supports, for example that required is a list of strings and minLength a whole number, and lists the ones that are wrong, but it does not validate the schema against the official meta-schema.
Why is there only one error for anyOf when two alternatives failed?
The rule that failed is anyOf itself: no alternative matched. The option lines under the message show the first problem with each alternative, which is usually enough to see which one the data was meant to match.