Skip to main content
CalcHive

JSON Schema Validator

New
Validation results will appear here...
Share:

Validate JSON data against a JSON Schema (Draft 7). Check types, required fields, string/number constraints, enums, patterns, and nested objects instantly in your browser.

How to Use JSON Schema Validator

  1. Paste your JSON data in the left text area.
  2. Paste your JSON Schema in the right text area.
  3. Click "Validate Against Schema" to check if the data conforms.
  4. Review validation errors with their paths and descriptions.
  5. Fix your JSON data and re-validate until all checks pass.

What is JSON Schema?

JSON Schema is a declarative language for defining the structure, data types, and constraints of JSON documents. It provides a contract that describes what valid JSON data looks like, allowing you to automatically validate API payloads, configuration files, form data, and any structured JSON input. JSON Schema is defined by the IETF and has evolved through several drafts, with Draft 7 being widely supported across languages and tools. The schema itself is written in JSON, making it both human-readable and machine-enforceable.

How Schema Validation Works

The validator compares your JSON data against the schema rules. It checks type constraints (string, number, integer, boolean, array, object, null), required properties, string constraints (minLength, maxLength, pattern), number constraints (minimum, maximum), enum values, array constraints (minItems, maxItems, uniqueItems), and object constraints (additionalProperties). When validation fails, error messages include JSON Pointer paths (like /address/city) that pinpoint exactly where the data does not conform to the schema. All validation runs entirely in your browser.

Common Use Cases

  • Validating REST API request and response payloads
  • Enforcing configuration file structure in CI/CD pipelines
  • Generating forms from schemas in admin panels and content management systems
  • Documenting API data contracts between frontend and backend teams
  • Validating webhook payloads from third-party integrations
  • Testing that mock data conforms to expected structures during development

Writing Effective JSON Schemas

Start with the type keyword to define whether your root value is an object, array, or primitive. Use required to list properties that must be present. Add constraints like minLength for strings to prevent empty values, minimum/maximum for numbers to enforce valid ranges, and pattern for strings that must match a specific format (like email or phone number regex). Set additionalProperties: false on objects to reject unexpected fields, which is useful for catching typos in configuration keys. For arrays, use items to define the type of each element, and uniqueItems: true when duplicates should not be allowed. Combining these keywords creates precise, self-documenting validation rules that serve as both documentation and enforcement.

For basic JSON syntax validation, use the JSON Validator. For formatting JSON data, try the JSON Formatter. For generating TypeScript types from JSON, see the JSON to TypeScript Converter.

Frequently Asked Questions

Related Tools

Was this tool helpful?