Check a JSON document against a JSON Schema and see every problem, each with the pointer to the value that is wrong. It runs in your browser.
What it does
Put the document in the first box and a JSON Schema in the second. The problems are listed as you type: where in the document each one is (a JSON Pointer, or (document) for the whole of it) and what is wrong. Hover a problem for the schema keyword that said so, and where that is in the schema.
Which draft
The draft is read from the schema's $schema: drafts 4, 6, 7, 2019-09 and 2020-12 are understood, and the newest is used when there is none. The status line says which was used.
Formats
Check formats holds strings to their format (email, date-time, uuid and so on). Recent drafts leave that to the validator, and most people expect it, so it is on.
Nothing is fetched
A schema is something you paste in, and it must not make a page read a URL: a $ref has to point inside the schema (#/$defs/name, an $id or an $anchor in it). A reference to somewhere else is reported as a problem with the schema. At most a thousand problems are listed.
In your tab
The check is made by the same Rust engine as the desktop app, compiled to WebAssembly: nothing is uploaded. The module that does it is about 500 KB, and is loaded on this page and on Create Schema only. Up to 10 MB a box here. To tidy a document first, use Format.
Lessons
Samples to study and to try: ▶ Try it puts them in the page.
A document that fits
A JSON Schema says what a document may be: the types of its values, the members its objects must have, the formats of its strings. Validate checks a document against one.
A person, as the schema says
Check formats: on
Samples: Document, Schema
Document
{
"name": "Ada",
"email": "[email protected]",
"age": 36,
"role": "lead",
"joined": "2021-03-01"
}Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 1 },
"email": { "type": "string", "format": "email" },
"age": { "type": "integer", "minimum": 0 },
"role": { "enum": ["lead", "dev", "qa"] },
"joined": { "type": "string", "format": "date" }
},
"required": ["name", "email"],
"additionalProperties": false
}What it gives: valid
The document is valid (Draft 2020-12)
required lists the members it must have; additionalProperties: false allows no others.format holds a string to being an email, a date… when Check formats is on.
What does not fit
Every problem is listed with where it is in the document — a JSON Pointer — what is wrong, and the keyword of the schema that said so.
A person with six things wrong
Check formats: on
Samples: Document, Schema
Document
{
"email": "ada(at)example.com",
"age": -1,
"role": "boss",
"joined": "2021-02-30",
"nickname": "A"
}Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 1 },
"email": { "type": "string", "format": "email" },
"age": { "type": "integer", "minimum": 0 },
"role": { "enum": ["lead", "dev", "qa"] },
"joined": { "type": "string", "format": "date" }
},
"required": ["name", "email"],
"additionalProperties": false
}What it gives: 6 problems
(document): "name" is a required property [required]
/email: "ada(at)example.com" is not a "email" [format]
/age: -1 is less than the minimum of 0 [minimum]
/role: "boss" is not one of "lead", "dev" or "qa" [enum]
/joined: "2021-02-30" is not a "date" [format]
(document): Additional properties are not allowed ('nickname' was unexpected) [additionalProperties](document) is the document itself: it lacks name.- The 30th of February is no date, and
boss is not one of the roles. - A click on a problem highlights it in the document, and the keyword in the schema.
References with $defs
A schema can name a part once, under $defs, and use it where it is needed with $ref. A reference has to point inside the schema: nothing is fetched.
Two addresses, one definition
Check formats: on
Samples: Document, Schema
Document
{
"billing": { "street": "1 Main St", "city": "Springfield", "zip": "12345" },
"shipping": { "street": "9 Side Rd", "zip": "1234" }
}Schema
{
"type": "object",
"properties": {
"billing": { "$ref": "#/$defs/address" },
"shipping": { "$ref": "#/$defs/address" }
},
"required": ["billing"],
"$defs": {
"address": {
"type": "object",
"properties": {
"street": { "type": "string" },
"city": { "type": "string" },
"zip": { "type": "string", "pattern": "^[0-9]{5}$" }
},
"required": ["street", "city", "zip"]
}
}
}What it gives: 2 problems
/shipping: "city" is a required property [required]
/shipping/zip: "1234" does not match "^[0-9]{5}$" [pattern]- Both addresses are held to
#/$defs/address; only shipping breaks it — no city, and a zip of four digits.
Your own queries, schemas, patches, documents and web addresses, kept in folders, with a sample if you like. It is the desktop app's workspace: a folder of the app opens here. This needs JavaScript.