Instance and schema
Parse errors only: JSON validator.
Schema result
Valid · compiled as 2020-12
Default age 21 is an integer ≥ 0, so the required property passes.
JSON Schema Validator - Draft 2020-12 Contracts in the Browser
Check whether a JSON instance matches a JSON Schema contract. Default {"age":21} against an integer minimum-0 schema is valid. Syntax-only parsing is a different tool.
What Is a JSON Schema Validator?
A JSON Schema validator is a contract checker, not a pretty-printer and not a syntax linter. JSON.parse only asks whether the text is JSON. JSON Schema asks whether the parsed value matches a declared shape: types, required keys, numeric ranges, enums, nested objects, array item rules, and optional format hints. The output of this page is valid or a list of Ajv errors with an instancePath such as /age - not an indented twin of your document.
JSON Schema is the usual way APIs, form backends, and config loaders describe “this object is acceptable.” OpenAPI request bodies, Kubernetes CRDs, GitHub Actions inputs, and many CMS plugins publish a schema so clients can fail fast instead of discovering a 400 after the network round-trip. Draft 2020-12 is the dialect this tool compiles first. Older draft-07 documents often still compile after a fallback, which is why a second Ajv instance exists on this page.
The default instance is {"age":21}. The default schema requires an object with integer age ≥ 0. Ajv reports valid. That is the worked check. Change age to -1 and minimum fails. Change it to the string "21" and type fails. Extra keys are allowed because the sample does not set additionalProperties to false - a closed object is a different contract you must write explicitly.
Compile uses Ajv’s 2020-12 dialect first. If compile throws because the schema is an older draft-07 document, the tool retries with Ajv draft-07. Draft-04 exclusiveMinimum-as-boolean quirks are not fully emulated. Remote $ref HTTP loads are not fetched - that would be a network side effect you did not ask for. Format keywords such as email are assisted by ajv-formats; treat them as lints, not a complete RFC of every format string.
How to Validate JSON Against a Schema - Step by Step
Validating a contract with this tool takes under a minute:
- Paste the instance JSON - The left panel holds the document you want to check. The default is
{"age":21}. You can replace it with any JSON value: object, array, string, number, boolean, or null. - Paste the JSON Schema - The schema must be a JSON object. The default requires an object with integer age greater than or equal to 0. Compile uses draft 2020-12 first, then draft-07 if needed.
- Read valid or the error list - The right panel shows Valid or Invalid plus the dialect Ajv used. Failed keywords include an instancePath such as
/ageand a message such as must be integer. - Fix the first failing keyword - Change the instance or the schema, then re-read the panel. Nothing is uploaded. Copy the report if you want to paste it into a ticket.
- Tighten the contract when you need a closed object - Add
additionalProperties: false,requiredarrays, and nestedpropertiesuntil the schema matches the API you actually ship. - Parse first if either side is broken JSON - If the instance or schema will not parse, use the JSON validator or JSON repair before this page. Ajv never sees invalid text.
JSON Schema Example - Valid Age vs Type Failure
Here is the default contract this page loads, plus the two cheapest ways to make it fail. The schema is unchanged in every row; only the instance changes.
Schema - integer age, minimum 0, required
{
"type": "object",
"properties": {
"age": { "type": "integer", "minimum": 0 }
},
"required": ["age"]
}Instance - valid (default)
{"age": 21}Result: Valid (2020-12). 21 is an integer and is greater than or equal to 0. The required property is present.
Instance - type failure
{"age": "21"}Result: Invalid. Ajv reports something like /age must be integer. JSON Schema does not coerce strings to numbers. That is the whole point of a contract: "21" and 21 are different values.
Instance - minimum failure
{"age": -1}Result: Invalid. The type is still integer, but minimum rejects negative ages. A syntax validator would call this document perfectly legal JSON. Only a schema can say “legal JSON, illegal age.”
When You Need JSON Schema Validation - Real-World Use Cases
Checking API request bodies before you send them
OpenAPI and many internal style guides publish a JSON Schema for POST and PUT bodies. Pasting a payload here catches missing required keys, wrong types, and out-of-range numbers before the request leaves your machine. That is faster than reading a 400 from a staging cluster, and it does not require a mock server.
Catching string-vs-number bugs in form JSON
HTML forms and some client libraries serialize numbers as strings. A syntax check will happily accept {"age":"21"}. A schema with type: integer will not. This is one of the most common production mismatches between a TypeScript interface that says number and a JSON body that says string.
Governing configuration files
Tools that load JSON config - linters, deploy manifests, feature-flag dumps - often ship a schema even when they also parse with JSON.parse. Validating a local config against that schema finds unknown enums, missing required blocks, and accidental extra keys (once you set additionalProperties false) without starting the whole application.
Teaching JSON Schema without installing Ajv
Draft 2020-12 vocabulary is easier to learn when you can change one keyword and see the error path update immediately. Students can keep the default age schema, then add maximum, enum, or nested properties without a Node toolchain. The dialect label in the result panel shows whether compile stayed on 2020-12 or fell back to draft-07.
Reviewing vendor schemas before you adopt them
Third-party APIs sometimes publish a schema that is draft-07 while your stack assumes 2020-12, or the reverse. Compiling here is a cheap compatibility check. If 2020-12 throws and draft-07 succeeds, you know you need an older validator in CI or a schema upgrade - not a mystery production failure.
Closing objects that should not grow extra keys
The default sample is an open object: extra properties pass. Many APIs want the opposite. Adding additionalProperties: false turns a typo such as agge into a validation error instead of a silently ignored field. That is a schema job. A formatter cannot see the typo; a syntax validator cannot see it either.
Linting format keywords locally
ajv-formats assists email, uri, and date-time. That is useful when you want a second pair of eyes on a payload that already parses. It is not a replacement for a dedicated email RFC library. Treat a format failure as a hint, then confirm against the spec your product actually promised.
Separating “is JSON” from “is our JSON”
Incident write-ups often confuse a parse error with a schema error. If the document will not parse, this page never reaches Ajv. If it parses and still fails, the report is a contract failure. Keeping those two tools separate - this page versus the JSON validator - makes the postmortem accurate.
Schema vs Syntax vs Format - Which Tool to Use
Three nearby tools on this site answer three different questions. Using the wrong one wastes time and produces the wrong error story:
| Question | JSON Schema | JSON validator | JSON formatter |
|---|---|---|---|
| Is the text RFC 8259 JSON? | Assumes yes | ✓ primary | Side effect of parse |
| Does age have to be an integer ≥ 0? | ✓ | ||
| Pretty-print or minify | ✓ | ||
| instancePath keyword errors | ✓ | ||
Trailing comma {"ok":true,} | Parse fails first | ✓ line/column | Parse fails |
| Draft 2020-12 compile | ✓ | ||
| Closed object via additionalProperties | ✓ | ||
| Human-readable indent | ✓ |
The general rule: parse first, then contract, then pretty-print. If the instance is not JSON, a schema cannot help. If it is JSON but the wrong shape, the formatter will happily indent the wrong shape. Schema is the middle step.
Common JSON Schema Errors - What Ajv Reports
These are the failures this page is built to surface. They are not RFC 8259 syntax errors; they are contract errors after a successful parse:
- Type mismatch.
{"age":"21"}againsttype: integerfails. Schema does not coerce. JavaScript might; JSON Schema must not if you asked for an integer. - minimum / maximum.
{"age":-1}againstminimum: 0fails even though the JSON is legal. Exclusive variants depend on the draft you compiled. - required missing. An empty object
{}against the default schema fails becauseageis required. The instancePath is usually/with a message that lists missing properties. - additionalProperties. The default sample allows extra keys. Once you set
additionalProperties: false, a typo key becomes an error instead of a silent extra field. - Schema is not an object. A schema that is an array or a primitive cannot compile. This page reports “Schema must be a JSON object.”
- Instance or schema is not JSON. Trailing commas, single quotes, and comments fail in
parseJsonDocumentbefore Ajv runs. The error names Instance or Schema plus line and column. - Compile failure / unknown dialect. If 2020-12 throws and draft-07 also throws, you see the compile message. Draft-04 exclusiveMinimum-as-boolean quirks are not fully emulated.
- Unresolved $ref. In-document refs that cannot be resolved fail compile. Remote HTTP
$refis not fetched. Inline the definition or resolve it locally first. - format is a lint. A failing
emailformat is useful, not a guarantee that every RFC 5322 edge case was implemented. Confirm against the product spec.
Privacy & Security - 100% Browser-Side Ajv
Instance JSON and schema JSON are compiled and evaluated in your browser with Ajv. No document is posted to a server. That makes the page usable for payloads that contain customer records, tokens, or internal field names - with the usual caveat that local storage on a shared machine is still on that machine.
Drafts are saved under a unique storage key for up to 30 days so you can refresh without losing the pair you were editing. Click Clear to restore the default {"age":21} instance and the integer minimum schema. Panel width is stored separately and is not the document. Remote schemas are never downloaded; a $ref to an HTTP URL will not leak the instance to a third host because this page does not follow that URL.
Frequently Asked Questions
What is JSON Schema validation?
Syntax checks ask whether a document is JSON. Schema checks ask whether the parsed value matches a contract: types, required keys, ranges, enums, nested objects, and optional format hints. This page compiles with Ajv using draft 2020-12 first, then retries draft-07 if compile throws. It is not a pretty-printer and not a syntax-only parser.
What does the default sample do?
The default instance is {"age":21} and the default schema is an object that requires age as an integer with minimum 0. Ajv reports valid. Change age to -1 and the minimum keyword fails. Change age to the string "21" and the type keyword fails. That is the worked check for this tool.
Is this the same as a JSON validator?
No. A JSON validator only runs a parse and reports the first line and column if RFC 8259 fails. This page assumes both the instance and the schema are JSON, then applies the schema. If either side will not parse, fix that on the JSON validator first, then come back here.
Which JSON Schema draft is supported?
Primary compile is JSON Schema draft 2020-12. If that fails because the schema is an older draft-07 document, the tool retries with Ajv’s draft-07 validator. Draft-04 exclusiveMinimum-as-boolean quirks are not fully emulated. Remote $ref HTTP loads are not fetched.
Are format assertions such as email enforced?
ajv-formats is loaded, so keywords like email, uri, and date-time are assisted. Treat format as a useful lint, not a complete RFC implementation of every format string. Some ecosystems treat format as an annotation rather than an assertion.
Does schema validation upload my data?
No. Ajv runs in the browser. The instance and schema stay in local storage for up to 30 days so you can resume a draft. Nothing is posted to a server. Do not paste production secrets if other people share the device.
What happens if the instance or schema is not valid JSON?
The schema engine never runs. You get a parse error that names the side that failed (Instance or Schema) plus line and column from parseJsonDocument. Repair small broken drafts on JSON repair, or check syntax on the JSON validator, then paste the clean documents here.
Does additionalProperties reject extra keys by default?
No. The default sample schema does not set additionalProperties to false, so extra keys are allowed. Add that keyword when you want a closed object. That difference is a common source of “it validated but the API still rejected it” surprises.
Can I validate against a remote $ref?
Not over the network. Fetching a remote schema would be a side effect this page does not perform. Inline the referenced definitions, or resolve $ref locally before pasting. The compile error will name the problem if a $ref cannot be resolved in-document.
Is this JSON Schema validator free?
Yes. No signup, no usage cap, and no premium dialect. Validate as many instance and schema pairs as you need. Processing stays on your device.
Related JSON Contract & Validation Tools
Schema is one step in a JSON workflow. These pages cover parse, repair, files, and presentation:
- JSON Validator - RFC 8259 syntax only, with line and column. Use it when the instance or schema will not parse.
- JSON Formatter - Pretty-print after the document is valid JSON. This schema page does not indent.
- JSON Repair - Heuristic fixes for small broken drafts before you paste them here.
- JSON5 Validator - Unquoted keys and trailing commas. That dialect is not JSON Schema input.
- JSON File Processor - Worker parse for files up to the documented 50 MB cap. Not a schema engine.
- JSON Compare - Diff two instances after both pass the same schema.
- JSON Query - JSONPath extraction once the contract is satisfied.
- JSON Editor - Edit objects as a table, then re-validate the result against your schema.
Related Tools
Discover more free developer tools that might interest you.
JSON Formatter
Format and validate JSON data
Use ToolJSON Viewer
View JSON data in a tree structure
Use ToolJSON Minifier
Minify JSON data to reduce size
Use ToolJSON Editor
Edit JSON in text, tree, and table modes. Works offline in the browser
Use ToolJSON Query
Query and transform JSON with JSONPath
Use ToolJSON Compare
Diff two JSON documents path by path
Use ToolRelated guides
Read the how-to, then come back to this tool when you are ready to run it locally.