Reading the errors
Each error names the failing value by its JSONPath, such as $.items[0].qty, and says what the schema expected. Select Show to jump to the value. When a value fails inside anyOf or oneOf, the error is reported once for the whole choice rather than once per alternative, which is usually the clearest.
How to use the JSON Schema Validator
- Paste a JSON Schema on the left and the JSON to validate on the right, or press Sample.
- The draft is taken from the schema's $schema; choose one if it has none.
- Read each error, and select Show to jump to the failing value.
Examples
Type, required and enum errors
schema: {"type":"object","properties":{"id":{"type":"integer"},"role":{"enum":["admin","user"]}},"required":["id","name"]}
data: {"id":"42","role":"root"}$: is missing the required property “name”
$.id: should be integer, but is string
$.role: should be one of "admin", "user"Errors inside arrays
schema: {"type":"array","items":{"type":"object","properties":{"qty":{"type":"integer","minimum":1}},"required":["qty"]}}
data: [{"qty":0},{}]$[0].qty: should be at least 1, but is 0
$[1]: is missing the required property “qty”No extra properties
schema: {"type":"object","properties":{"name":{"type":"string"}},"additionalProperties":false}
data: {"name":"web","nmae":"typo"}$.nmae: “nmae” isn't allowed hereadditionalProperties: false catches misspelt property names.
Formats
Since draft 2019-09, format is only an annotation unless a validator is told to assert it, and validators differ. With Check formats on (the default), email, uri, uuid, date, date-time and other common formats are checked, as most API validators do. Turn it off to ignore them.
Options
- Draft
- From $schema (the default), or 2020-12, 2019-09, draft 7 or draft 4.
- Check formats
- Treat
formatas a rule to check (on by default) or as an annotation only.
Limitations
$refs to other files or URLs aren't fetched; put referenced definitions in the schema's$defs(ordefinitions).- Numbers are compared as JavaScript numbers, so integers beyond 2^53 lose precision.
- Error messages for less common keywords use the validator's own English wording.
Frequently asked questions
Is my data uploaded?
No. Validation runs in your browser; neither the schema nor the JSON is sent anywhere.
Which draft should I use?
The one your schema declares in $schema, or that your validator uses. OpenAPI 3.1 uses 2020-12; OpenAPI 3.0 uses an extended subset of draft 4 (draft 7 is a good approximation).
How do I get a schema for my JSON?
Generate one from a sample with the JSON Schema Generator, then tighten it.
Is this the same as Ajv?
It follows the same specification. It uses a validator that interprets schemas instead of compiling them to code, so it runs safely in the page.