📐 JSON Schema
Paste a JSON Schema (Draft 2020-12 by default). Other drafts work if the schema declares
$schema, but only the 2020-12 dialect is loaded.
📄 JSON Instance
The JSON document to validate against the schema above.
📤 Result
ℹ️ About JSON Schema Validator
What is JSON Schema?
JSON Schema is a declarative language that describes the shape of JSON data. A schema tells consumers which fields are required, what types values may take, what ranges and patterns apply, and how composite documents nest. The 2020-12 draft is the current version maintained by the JSON Schema project at json-schema.org/draft/2020-12.
This validator runs entirely in your browser for normal page use; the same TypeScript logic module is
also exposed via the API endpoint below, so client and server agree byte-for-byte on what counts as a
valid instance. The validation engine is
Ajv with
ajv-formats
enabled, so standard formats such as date-time, email, uri,
ipv4, uuid, and friends are checked.
When to use schema validation
- API contracts — confirm a request or response body matches an OpenAPI schema or an internal data contract before further processing.
- Configuration files — validate
config.json, CI manifests, or infrastructure-as-code documents in pull requests. - ETL pipelines — gate an extract or load step on the upstream JSON conforming to the agreed shape.
- Schema authoring — iterate on a schema against representative instance documents and see exactly which keyword path failed and why.
- Data quality monitoring — drop a schema in front of a webhook to log non-conforming payloads instead of letting them propagate.
Common keywords (Draft 2020-12)
- type —
"string","number","integer","boolean","object","array","null". - required — array of property names that must be present on the object.
- properties, additionalProperties, patternProperties
— control which keys an object may carry.
additionalProperties: falserejects extras. - minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf — numeric constraints.
- minLength, maxLength, pattern,
format — string constraints (
formatuses ajv-formats). - items, prefixItems, minItems, maxItems, uniqueItems — array constraints.
- enum, const — restrict an instance to an explicit set or single value.
- allOf, anyOf, oneOf, not — schema composition.
- $ref, $defs — reuse subschemas via JSON Pointer references.
Worked example
Schema:
{
"type": "object",
"required": ["name"],
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 }
}
}
Valid instance:
{ "name": "Ada", "age": 36 }
Invalid instance — missing name, fails required:
{ "age": 36 }
Error reporting
Every error returned by the validator carries:
- keyword — the schema keyword that produced the failure
(e.g.
required,type,enum,format). - instancePath — JSON Pointer to the failing location in the instance
(e.g.
/items/2/age). - schemaPath — JSON Pointer to the failing keyword in the schema
(e.g.
#/properties/age/minimum). - message — human-readable description from Ajv.
- params — keyword-specific data (e.g. the missing property name for
required, the limit forminimum).
The validator runs with allErrors: true, so a single invocation surfaces every error
instead of stopping at the first one.
References
- JSON Schema Draft 2020-12 specification — current draft, the default used by this validator.
- JSON Schema getting started guide — beginner-friendly tutorial.
- Ajv — the JSON Schema validator — implementation used here.
- RFC 6901
— JSON Pointer, the syntax used for
instancePathandschemaPath.
API Usage Example:
POST /api/tools/data/json-schema-validator
Content-Type: application/json
{
"schema": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"instance": {
"name": "Ada",
"age": 36
}
}