Home › Blog › JSON Schema Guide
JSON Schema Validator Guide: Validate JSON Online
JSON Schema describes the shape of JSON data: allowed types, required properties, array items, formats, ranges, and nested objects. A validator checks an instance against that contract.
Validate JSON against a schema →
Schema versus instance
The schema is the rulebook; the instance is the data being checked. A schema can require name to be a string and age to be an integer greater than zero. The same schema can validate thousands of different instances, and one instance can be checked against several schemas at different layers of a system.
Worked example
Schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["id", "email"],
"properties": {
"id": { "type": "integer", "minimum": 1 },
"email": { "type": "string", "format": "email" },
"role": { "enum": ["admin", "editor", "viewer"] }
},
"additionalProperties": false
}Valid instance: { "id": 7, "email": "a@b.com", "role": "editor" }
Invalid instance: { "id": 0, "role": "owner", "name": "Ada" } fails four ways — email is missing, id is below the minimum, role is not in the enum, and name is not an allowed property.
Common keywords
| Keyword | Purpose |
|---|---|
type | string, number, integer, boolean, object, array, null |
required | Property names that must be present |
enum / const | Restrict to a fixed set, or a single value |
minimum / maximum | Numeric bounds |
minLength / maxLength / pattern | String length and regex |
items / minItems / uniqueItems | Array element rules |
additionalProperties | Allow or reject unlisted properties |
What validation catches
- Missing required properties.
- Wrong primitive types, such as a numeric string where a number is expected.
- Unexpected properties when
additionalPropertiesis false. - Invalid formats such as email or date strings.
- Values outside numeric or length limits.
Use validation at boundaries
Validate API requests, webhook payloads, configuration files, and imported data before business logic touches them. Keep schemas versioned with the application, return the failing JSON path in error messages, and fail fast so bad data never reaches the database. Draft 2020-12 is current; draft-07 is still common and fine for older tooling. Declare the draft with $schema.
Frequently asked questions
Which draft should I target?
Draft 2020-12 is current and best supported by new tooling. Draft-07 is still widely used and safe if your validator or OpenAPI version is older. Declare it with $schema.
What does additionalProperties do?
Extra properties are allowed by default. Setting it to false rejects any property not named in properties or matched by patternProperties, catching typos and stray fields.
Does format enforce anything?
It depends on the validator. Formats like email and uri are checked only when format validation is explicitly enabled, so do not rely on them for security.
Can I generate a schema from existing JSON?
Yes. A generator infers types and required fields from a sample, giving a starting point you then tighten with enums, ranges, and descriptions.
Related NeatJSON tools: JSON to Schema Generator, JSON Validator, JSON to TypeScript, JSON to Pydantic.
Validation runs entirely in your browser. Neither the schema nor the data is uploaded.