Hunt
Skip to content

JSON Schema Validator

Paste a JSON Schema and a JSON document to see whether the document is valid, and if not, every error with the path of the failing value and a plain-English explanation. Drafts 4, 7, 2019-09 and 2020-12 are supported, and the schema itself is checked against its draft. Nothing is uploaded.

Runs in your browser

Schema

JSON

Result

Paste a schema and JSON to validate it.

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

  1. Paste a JSON Schema on the left and the JSON to validate on the right, or press Sample.
  2. The draft is taken from the schema's $schema; choose one if it has none.
  3. Read each error, and select Show to jump to the failing value.

Examples

Type, required and enum errors

Input
schema: {"type":"object","properties":{"id":{"type":"integer"},"role":{"enum":["admin","user"]}},"required":["id","name"]}
data: {"id":"42","role":"root"}
Output
$: is missing the required property “name”
$.id: should be integer, but is string
$.role: should be one of "admin", "user"

Errors inside arrays

Input
schema: {"type":"array","items":{"type":"object","properties":{"qty":{"type":"integer","minimum":1}},"required":["qty"]}}
data: [{"qty":0},{}]
Output
$[0].qty: should be at least 1, but is 0
$[1]: is missing the required property “qty”

No extra properties

Input
schema: {"type":"object","properties":{"name":{"type":"string"}},"additionalProperties":false}
data: {"name":"web","nmae":"typo"}
Output
$.nmae: “nmae” isn't allowed here

additionalProperties: 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 format as 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 (or definitions).
  • 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.