jsondecode.com logo

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)

KeywordApplies toDescription
typeanyConstrains the value type: string, number, integer, boolean, array, object, null
requiredobjectArray of property names that must be present
propertiesobjectSchema for each named property
additionalPropertiesobjectSchema (or false) for properties not listed in properties
minLength / maxLengthstringMinimum and maximum character count
patternstringECMAScript regex the string must match
formatstringSemantic format: email, date, uri, uuid, date-time, etc.
minimum / maximumnumberInclusive lower/upper bound
exclusiveMinimum / exclusiveMaximumnumberExclusive lower/upper bound (Draft-07: number value)
multipleOfnumberValue must be divisible by this number
minItems / maxItemsarrayMinimum and maximum array length
itemsarraySchema for each array element (or tuple schemas)
uniqueItemsarrayAll array items must be distinct
enumanyValue must be one of the listed values
constanyValue must equal exactly this value
anyOfanyValid if the instance is valid against at least one subschema
oneOfanyValid if the instance is valid against exactly one subschema
allOfanyValid if the instance is valid against all subschemas
notanyValid if the instance is NOT valid against the subschema
if / then / elseanyConditional validation: if matches, apply then; otherwise apply else
$refanyReference to another schema by JSON Pointer or URI
definitions / $defsschemaReusable schema definitions referenced via $ref

JSON Schema draft versions

Draft$schema URINotes
Draft-04http://json-schema.org/draft-04/schema#Widely supported. exclusiveMinimum/Maximum were booleans.
Draft-06http://json-schema.org/draft-06/schema#Added const, contains, propertyNames. exclusiveMin/Max changed to numbers.
Draft-07http://json-schema.org/draft-07/schema#Most widely used. Added if/then/else, readOnly, writeOnly, $comment.
Draft 2019-09https://json-schema.org/draft/2019-09/schemaAdded $anchor, $recursiveRef, unevaluatedProperties.
Draft 2020-12https://json-schema.org/draft/2020-12/schemaLatest. 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.

If jsondecode.com saved you time, share it with your team

Free forever. No ads. No sign-up. Help other developers find it.