JSON Schema Validator
Validate JSON data against a JSON Schema and see exactly which fields violate it. Everything runs locally in your browser.
Your schema and data are validated in this browser and are never sent to Docspira. Learn more.
About JSON Schema validation
JSON Schema validation checks that JSON data has the shape a schema describes: required fields, types, string/number/array/object rules, composition (allOf/anyOf/oneOf/not), conditionals (if/then/else), and more; not just that the data is syntactically valid JSON (that's what the JSON Formatter checks). This tool supports Draft 7, Draft 2019-09, and Draft 2020-12; it reads your schema's "$schema" field to pick the right one, and defaults to Draft 7 when that field is missing. Format keywords (email, date, date-time, uri, hostname, ipv4, ipv6, uuid, and more) are checked using ajv-formats. Local, self-contained references (like #/$defs/User) work normally; a schema that references a remote http(s):// URL is rejected with a clear message instead of being fetched; this tool never makes a network request. Nothing you paste is uploaded, logged, or stored.
What this tool does
Validate JSON data against a JSON Schema in the browser.
How to use
- Paste a JSON Schema and the JSON data to check.
- Choose the supported draft and validation options you need.
- Run validation and review the reported paths and messages.
How to read a validation error
Each error has three parts. Take this one:
/user/age type must be integer
- Path (
/user/age): where in your data the problem is, as a JSON Pointer. An empty path means the root object. - Keyword (
type): which rule in your schema failed. This tells you which part of the schema to look at. - Message: what the rule expected.
If you get many errors at once, fix the ones with the shortest paths first. A wrong type on a parent object often causes a cascade of errors on its children.
Annotated example schema
A realistic schema for a user signup payload. Paste it with the sample data to see it pass, then break the data to see each rule fire.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["email", "age"],
"properties": {
"email": { "type": "string", "format": "email" },
"age": { "type": "integer", "minimum": 13 },
"nickname": { "type": ["string", "null"], "maxLength": 32 },
"plan": { "enum": ["free", "pro"] },
"tags": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true
}
},
"additionalProperties": false
}
{ "email": "ana@example.com", "age": 29, "nickname": null, "plan": "free", "tags": ["beta"] }
What each line is doing:
requiredlists keys that must be present. It sits next toproperties, not inside each property."type": "integer"rejects29.5and also rejects the string"29". JSON Schema never coerces types."type": ["string", "null"]is how you allownull. See thenullablenote below.enumaccepts only the listed values, compared exactly (case sensitive).additionalProperties: falserejects any key not listed inproperties. Without it, a typo like"emial"passes silently.
7 schema mistakes that make validation lie
These all produce a schema that looks right and quietly accepts bad data, or fails in a confusing way. Each one was tested with Ajv, the most widely used JavaScript validator.
1. No additionalProperties: false, so typos pass.
With a schema that only lists email, the data {"email": "a@b.c", "emial": "x"} is valid. Add "additionalProperties": false and it fails with must NOT have additional properties (emial).
2. "required": true inside a property.
That's Draft 3 syntax. In every modern draft, required is an array on the parent object. Ajv refuses to compile the schema: required must be array.
3. Expecting format to be enforced everywhere.
In Draft 2019-09 and 2020-12, format is an annotation by default: a validator is allowed to ignore it. This tool does check formats (email, date-time, uri, uuid and more), but your production validator may not. In Ajv, for example, "format": "email" is only enforced after you add the ajv-formats plugin. If invalid emails pass in your app but fail here, this is why.
4. Using nullable: true.
nullable comes from OpenAPI 3.0, not from JSON Schema. Some validators accept it, most ignore it. The portable form is "type": ["string", "null"].
5. oneOf with overlapping options.
{"oneOf": [{"type": "number"}, {"type": "integer"}]} rejects 5, because 5 matches both and oneOf means exactly one. Use anyOf unless you really need exclusivity.
6. additionalProperties: false combined with allOf.
additionalProperties only sees the properties declared next to it, not the ones inside allOf. So properties defined in the allOf branch get rejected as "additional". In Draft 2019-09 and later, use "unevaluatedProperties": false instead; it sees through allOf, anyOf and $ref.
7. Tuple syntax from the wrong draft.
In Draft 7, a tuple is "items": [ {...}, {...} ]. In 2020-12 that became "prefixItems": [ ... ], and items must be a single schema. An array-form items under 2020-12 is a schema error. Check that $schema matches the syntax you wrote.
Which draft should I use?
| Draft 7 | 2019-09 | 2020-12 | |
|---|---|---|---|
$schema URI |
http://json-schema.org/draft-07/schema# |
https://json-schema.org/draft/2019-09/schema |
https://json-schema.org/draft/2020-12/schema |
| Tuples | items: [...] + additionalItems |
items: [...] + additionalItems |
prefixItems: [...] + items |
Close an object across allOf |
not possible | unevaluatedProperties |
unevaluatedProperties |
| Reusable definitions | definitions |
$defs |
$defs |
| Used by | most older tooling, many IDEs | rare | OpenAPI 3.1, new projects |
For a new schema with no constraints, use 2020-12. If the schema will be consumed by an older tool, check what it supports; Draft 7 is still the safest common denominator.
FAQ
Is my JSON sent to a server?
No. Schema and data are validated in your browser with JavaScript and never sent to Docspira. You can verify it in the Network tab of your browser's developer tools.
Why does an invalid email pass in my app but fail here?
This tool checks format keywords. Many validators don't by default, because recent drafts treat format as an annotation. Enable format checking in your library (in Ajv, add ajv-formats). See mistake 3 above.
Which draft is used if my schema has no $schema?
Draft 7. Add a $schema line to choose 2019-09 or 2020-12 explicitly.
How do I allow null for a field?
Use "type": ["string", "null"] (or whatever the base type is). Avoid nullable: true, which is OpenAPI 3.0 syntax and not part of JSON Schema.
How do I reject unknown fields?
Add "additionalProperties": false to the object. If the object is built with allOf or $ref, use "unevaluatedProperties": false (Draft 2019-09 or later).
Can I validate YAML against a JSON Schema?
Yes. Convert it with the YAML to JSON converter, then paste the JSON here. Check the syntax first with the YAML validator.
Does it support $ref?
References inside the same schema (like "$ref": "#/$defs/address") work. A $ref to a remote http(s):// URL is rejected with a clear message instead of being fetched, because this tool never makes network requests.
Validation scope
A schema describes the rules you supply; test representative valid and invalid examples to verify those rules mean what you intend.
Privacy
This tool runs in your browser; the text or file you choose is not uploaded for processing. Read the privacy details.