JSON Schema Validator and Generator
Validate JSON against draft 2020-12, 2019-09, 07 or 06 schemas with every error and its JSON Pointer path, or generate a starter schema from sample JSON.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the JSON Schema Validator and Generator?
Paste a JSON Schema and a JSON document and this validator tells you, as you type, whether the document conforms. When it does not, you get every error at once rather than the first one: the JSON Pointer path of the failing value, a readable message, the value itself and the schema rule that rejected it. Validation is done by Ajv, the validator used by most JavaScript tooling, with support for drafts 2020-12, 2019-09, 07 and 06.
The Generate schema tab works the other way round. Paste an example payload, or an array of several, and get a draft 2020-12 or draft-07 schema with types, nested objects, array item schemas, required keys and detected formats such as date-time, email and uuid. Keys that are missing from some of the sample objects are left optional, so a list of records produces a realistic schema rather than one that only fits the first record.
Both directions run in your browser, so internal API payloads and customer records never leave your machine.
- Ajv validation for drafts 2020-12, 2019-09, 07 and 06
- All errors with JSON Pointer path, value and failing rule
- RFC 3339 date and time checks with leap years
- Formats: email, uri, uuid, ipv4, ipv6, hostname, duration and more
- Schema generator with merged array samples and optional keys
- Line and column for invalid JSON
- Runs locally in the browser
How to use the JSON Schema Validator and Generator
- On the Validate tab, paste your schema on the left and the JSON document on the right. The sample shows an order with several mistakes.
- Leave Draft on Auto to use the schema's $schema value, or force a draft if the schema has none.
- Read the result: a green confirmation, or a list of errors with the path, message, actual value and the rule that failed.
- To create a schema instead, open Generate schema, paste one example or an array of examples, and choose the draft and options.
- Copy or download the generated schema, or press Validate with this schema to test documents against it straight away.
Worked examples
Two problems reported together
Input
Schema requires host and port (integer, 1 to 65535). Data: {"port":70000}Output
(root): must have required property 'host' /port: must be <= 65535
Ajv runs with allErrors, so you see the missing key and the out-of-range value in one pass instead of fixing them one at a time.
Calendar-aware dates
Input
"placed": "2026-02-30T10:00:00Z" with format: date-time
Output
/placed: must match format "date-time"
A pattern-only check would accept February 30. The RFC 3339 check here validates the day against the month and leap years.
Schema from one object
Input
{"name":"Ada","age":36,"email":"ada@example.com"}Output
type object; name string, age integer, email string with format email; all three required
Whole numbers become integer, and the email format is detected. With an array of samples, keys missing from any object are not required.
Background and insight
JSON Schema is a vocabulary for describing the shape of JSON, developed as a series of IETF Internet-Drafts. Draft-04 (2013) was the long-lived early version, draft-06 and draft-07 (2017 and 2018) added const, contains, if/then/else and readOnly, draft 2019-09 introduced $defs, dependentRequired and unevaluatedProperties, and draft 2020-12 replaced the array form of items with prefixItems and added $dynamicRef. OpenAPI 3.1 uses draft 2020-12 for its schema objects, which is why it is the default here.
The validator reads $schema to choose the draft and falls back to 2020-12. Draft-06 schemas are checked with draft-07 rules, which only added keywords, and draft-04 schemas are accepted with a warning because their boolean exclusiveMinimum and exclusiveMaximum mean something different from later drafts. Error locations use JSON Pointer (RFC 6901), the same notation as the schemaPath that identifies the failing rule.
Formats deserve a note. Since draft 2019-09 the format keyword is an annotation by default, and validators may or may not enforce it. This tool enforces the common ones with real rules: date and date-time follow RFC 3339 with a calendar check (2024-02-29 passes, 2023-02-29 fails), ipv4 and ipv6 follow the RFC address grammars, and email, hostname, uri, uuid, duration, json-pointer and regex are checked too. Unknown formats produce a warning instead of failing the whole schema.
Common use cases
Debugging API payloads
Find out exactly which field of a request body breaks an OpenAPI or AsyncAPI contract.
Writing a new schema
Start from a generated schema for a real payload, then tighten it with enums, ranges and patterns.
Config file validation
Check package.json-style configs, VS Code settings or CI files against their published schemas.
Test fixtures
Confirm that sample data and mock responses still match the schema after the contract changes.
Learning JSON Schema
Experiment with keywords such as oneOf, if/then/else and unevaluatedProperties and see the effect immediately.
Tips and limitations
- additionalProperties: false only sees properties declared in the same schema object. With allOf composition use unevaluatedProperties: false (2019-09 and later) instead.
- A schema without type accepts every type. {"minimum": 0} alone happily validates the string "abc", because minimum only applies to numbers.
- $ref to remote URLs is not fetched. Paste referenced definitions into $defs and point to them with "#/$defs/name".
- Inferred schemas describe the sample, not the rules. Review every required list and add constraints before using one as a contract.
- JSON numbers like 1.0 parse as 1, so the generator calls them integer. Mark the field as number if fractional values are allowed.
Frequently asked questions
Which JSON Schema version should I use?
Use draft 2020-12 for new work, especially with OpenAPI 3.1. Draft-07 is still common in older tooling and editors. The validator detects the draft from $schema, so existing schemas work as they are.
Why does my document pass even though a field is wrong?
Usually the property is not covered by a constraint, for example a misspelled key in properties, a missing type, or a format that is not enforced. Check that the schema path you expect actually appears in the schema.
Are formats like email and date-time enforced?
Yes in this tool. The specification treats format as an annotation by default from 2019-09 on, so other validators may ignore it unless configured. Here the common formats are checked with their RFC rules.
How does the generator decide which properties are required?
A key is marked required when it appears in every sampled object at that position. Paste several examples as an array to let optional keys show up as optional, or switch the option off to make nothing required.
Can it resolve $ref to another file or URL?
Internal references such as #/$defs/address work. Remote references are not downloaded, which keeps the tool offline; copy those definitions into $defs instead.
Is my data sent to a server?
No. Ajv and the schema generator run inside the page, so the schema and the document stay in your browser.
Is there an in-depth guide to the JSON Schema Validator and Generator?
Yes. “JSON Schema Validation: Drafts, Keywords and Reading Errors” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
People also search for
- validate json against schema online
- generate json schema from json example
- json schema draft 2020-12 validator
- json schema required vs optional properties
- additionalproperties false explained
- json schema date-time format validation
- difference between draft-07 and 2020-12
- test openapi request body schema
Related Tools You May Like
Free, in-browser tools that pair well with this one.