JSON Schema Validator
Validate a JSON document against a JSON Schema (Draft-07). Runs entirely in your browser using AJV — no data sent to any server.
About JSON Schema Validator
JSON Schema is a vocabulary for annotating and validating JSON documents. A schema describes the expected shape of a JSON document — which fields are required, what types they must be, minimum/maximum values, string patterns, and more. It is defined in a series of IETF drafts; Draft-07 is the most widely deployed version and what this tool validates against.
This tool uses AJV (Another JSON Validator), the fastest and most spec-compliant JSON Schema validator available in JavaScript. AJV compiles schemas to optimized functions for maximum speed and supports all Draft-07 keywords including $ref, anyOf, oneOf, allOf, not, and format validators. All validation runs client-side — no schema or document data is sent to any server.
JSON Schema keyword reference (Draft-07)
| Keyword | Applies to | Description |
|---|---|---|
| type | any | Constrains the value type: string, number, integer, boolean, array, object, null |
| required | object | Array of property names that must be present |
| properties | object | Schema for each named property |
| additionalProperties | object | Schema (or false) for properties not listed in properties |
| minLength / maxLength | string | Minimum and maximum character count |
| pattern | string | ECMAScript regex the string must match |
| format | string | Semantic format: email, date, uri, uuid, date-time, etc. |
| minimum / maximum | number | Inclusive lower/upper bound |
| exclusiveMinimum / exclusiveMaximum | number | Exclusive lower/upper bound (Draft-07: number value) |
| multipleOf | number | Value must be divisible by this number |
| minItems / maxItems | array | Minimum and maximum array length |
| items | array | Schema for each array element (or tuple schemas) |
| uniqueItems | array | All array items must be distinct |
| enum | any | Value must be one of the listed values |
| const | any | Value must equal exactly this value |
| anyOf | any | Valid if the instance is valid against at least one subschema |
| oneOf | any | Valid if the instance is valid against exactly one subschema |
| allOf | any | Valid if the instance is valid against all subschemas |
| not | any | Valid if the instance is NOT valid against the subschema |
| if / then / else | any | Conditional validation: if matches, apply then; otherwise apply else |
| $ref | any | Reference to another schema by JSON Pointer or URI |
| definitions / $defs | schema | Reusable schema definitions referenced via $ref |
JSON Schema draft versions
| Draft | $schema URI | Notes |
|---|---|---|
| Draft-04 | http://json-schema.org/draft-04/schema# | Widely supported. exclusiveMinimum/Maximum were booleans. |
| Draft-06 | http://json-schema.org/draft-06/schema# | Added const, contains, propertyNames. exclusiveMin/Max changed to numbers. |
| Draft-07 | http://json-schema.org/draft-07/schema# | Most widely used. Added if/then/else, readOnly, writeOnly, $comment. |
| Draft 2019-09 | https://json-schema.org/draft/2019-09/schema | Added $anchor, $recursiveRef, unevaluatedProperties. |
| Draft 2020-12 | https://json-schema.org/draft/2020-12/schema | Latest. prefixItems replaces tuple items. $dynamicRef added. |
Example: full JSON Schema (Draft-07)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "User",
"type": "object",
"required": ["id", "email"],
"properties": {
"id": { "type": "integer", "minimum": 1 },
"email": { "type": "string", "format": "email" },
"name": { "type": "string", "minLength": 1, "maxLength": 100 },
"role": { "type": "string", "enum": ["admin", "editor", "viewer"] },
"age": { "type": "integer", "minimum": 0, "maximum": 150 },
"tags": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
"address": {
"type": "object",
"properties": {
"street": { "type": "string" },
"city": { "type": "string" }
}
}
},
"additionalProperties": false
}Validate JSON schema programmatically
JavaScript / Node.js (AJV)
import Ajv from 'ajv';
const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
const valid = validate(data);
if (!valid) console.log(validate.errors);Python (jsonschema)
import jsonschema jsonschema.validate(instance=data, schema=schema)
Python (fastjsonschema)
import fastjsonschema validate = fastjsonschema.compile(schema) validate(data) # raises JsonSchemaValueException if invalid
Go (gojsonschema)
import "github.com/xeipuuv/gojsonschema" result, _ := gojsonschema.Validate( gojsonschema.NewBytesLoader(schemaBytes), gojsonschema.NewBytesLoader(docBytes), )
Java (everit)
SchemaLoader loader = SchemaLoader.load(rawSchema); Schema schema = loader.load().build(); schema.validate(new JSONObject(jsonString));
Frequently asked questions
What is the difference between JSON Schema and TypeScript interfaces?▾
TypeScript interfaces are compile-time constructs — they enforce types during development but are erased at runtime. JSON Schema is a runtime validation standard — you use it to validate actual JSON data coming from APIs, user input, or files. They serve different purposes; tools like json-schema-to-typescript can generate one from the other.
What is the difference between anyOf, oneOf, and allOf?▾
allOf: the instance must be valid against all listed schemas (intersection). anyOf: the instance must be valid against at least one schema (union). oneOf: the instance must be valid against exactly one schema — it fails if more than one matches. Use anyOf for permissive unions, oneOf when types are mutually exclusive.
How do I validate an array of objects?▾
Use type: 'array' with an items keyword pointing to the object schema: { "type": "array", "items": { "type": "object", "required": ["id"], "properties": { "id": { "type": "integer" } } } }. Set minItems and maxItems to constrain array length.
What does additionalProperties: false do?▾
It rejects any property in the JSON document that is not listed in the properties keyword. This creates a closed schema — strict whitelisting. Without it (the default), extra properties are allowed. Use it when you want to ensure no unexpected keys are present.
How do I make a field optional with a type constraint?▾
Simply don't include it in the required array. Properties listed in properties but not in required are optional — they are only validated if present. To allow a field to be either a string or null, use: { "type": ["string", "null"] }.
What JSON Schema formats does AJV support?▾
With ajv-formats installed, AJV supports: date, time, date-time, duration, email, idn-email, hostname, idn-hostname, ipv4, ipv6, uri, uri-reference, iri, iri-reference, uuid, uri-template, json-pointer, relative-json-pointer, and regex. This tool has ajv-formats enabled.
Related Tools
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.