DevBolt
Processed in your browser. Your data never leaves your device.

How do I validate JSON against a JSON Schema online?

Paste your JSON data and JSON Schema (Draft 07) to instantly validate the data against the schema. The tool reports all validation errors with paths to the failing fields. You can also generate a schema from sample JSON data. Everything runs in your browser — your data never leaves your device.

Validate object against schema
Input
Schema: { "type": "object",
  "required": ["name", "age"] }
Data: { "name": "Alice", "age": 30 }
Output
✓ Valid
All required properties present
Type checks passed: 2/2
← Back to tools

JSON Schema Validator

Validate JSON data against a JSON Schema (Draft 07) with detailed error reporting. Generate schemas from sample data or load examples to get started.

Load example:
JSON Schema Quick Reference

JSON Schema is a vocabulary for annotating and validating JSON documents. It describes the structure, constraints, and documentation of JSON data.

Common keywords:
  • type — Data type: string, number, integer, boolean, object, array, null
  • required — Array of required property names
  • properties — Object property schemas
  • items — Schema for array elements
  • enum — Allowed values
  • pattern — Regex pattern for strings
  • minimum / maximum — Number range constraints
  • minLength / maxLength — String length constraints
  • format — Semantic format: email, uri, date-time, ipv4, uuid, etc.
  • additionalProperties — Allow or deny extra properties on objects
Combining schemas:
  • allOf — Must match all schemas
  • anyOf — Must match at least one schema
  • oneOf — Must match exactly one schema
  • not — Must not match the schema

This tool supports JSON Schema Draft 07 with format validation (email, URI, date-time, etc.) via ajv-formats. Everything runs in your browser — no data is sent over the network.

Tips & Best Practices

Pro Tip

Use $ref to keep schemas DRY and maintainable

Instead of repeating the same address object definition in user, order, and shipping schemas, define it once in $defs and reference it: {"$ref": "#/$defs/address"}. This mirrors how TypeScript interfaces work. Changes to the address schema automatically propagate to all references.

Common Pitfall

additionalProperties defaults to true — your schema allows anything

Without "additionalProperties": false, a schema requiring {name, email} happily accepts {name, email, isAdmin: true}. This is a common source of mass assignment vulnerabilities. Always set additionalProperties explicitly. Use "additionalProperties": false in strict APIs and true only when extensibility is intentional.

Real-World Example

Combine allOf, oneOf, anyOf for complex validation

allOf: all schemas must match (intersection, like TypeScript &). oneOf: exactly one must match (discriminated union). anyOf: at least one must match (union, like TypeScript |). Use oneOf with a discriminator field for tagged unions: {"oneOf": [{type: "card"}, {type: "bank"}], "discriminator": {"propertyName": "type"}}.

Security Note

Validate schema constraints server-side, not just client-side

Client-side JSON Schema validation improves UX but provides zero security. Attackers bypass your frontend entirely. Every API endpoint must validate request bodies server-side against the schema. Use AJV (JavaScript), jsonschema (Python), or similar libraries as middleware in your API handler.

Frequently Asked Questions

What is JSON Schema and why use it for API validation?
JSON Schema is a declarative vocabulary for defining the structure, types, and constraints of JSON data. It specifies required fields, data types, string patterns, numeric ranges, array constraints, enum values, and nested structures. JSON Schema catches invalid request payloads before your business logic runs, generating precise error messages. It also serves as machine-readable API documentation. Most API frameworks support JSON Schema validation natively or through middleware. DevBolt's validator lets you test schemas against sample data instantly.
How do I define optional vs required fields in JSON Schema?
All properties are optional by default. Required fields are listed in the required array at the object level. Define properties with types and constraints, then add required field names to the required array. A field present with null satisfies required unless you restrict the type to exclude null. For nested objects, each level has its own independent required array.
What is the difference between JSON Schema Draft-07 and Draft 2020-12?
Draft 2020-12 added $dynamicRef for extensible recursive schemas, prefixItems for clearer tuple validation, $vocabulary for feature declarations, and unevaluatedProperties for better additional content control. Despite improvements, Draft-07 remains the most widely supported version. For new projects, Draft 2020-12 offers better expressiveness, but verify your validator library supports it before adopting.

Related Inspect Tools