🔧 JSON Tool Pro

Format · Validate · Diff · Java POJO · TypeScript · CSV · Escape · JSONPath

← Back to Blog

JSON Schema Validator Guide — Validate JSON Data Like a Pro

Published: July 22, 2026

JSON Schema is a powerful tool for defining the structure and constraints of JSON data. Whether you're validating API requests, ensuring database consistency, or generating documentation, JSON Schema helps you catch data quality issues before they cause problems.

Try it now: Use our free JSON Schema Validator to validate your JSON data against any schema instantly. 100% client-side, no uploads.

What is JSON Schema?

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It defines the expected structure, data types, and constraints for JSON data. Think of it as a contract that your JSON data must follow.

Basic Example

Here's a simple JSON Schema for a user object:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["name", "email"],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 100
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "age": {
      "type": "integer",
      "minimum": 0,
      "maximum": 150
    },
    "isActive": {
      "type": "boolean"
    }
  }
}

This schema validates that the JSON data:

  • Is an object (not an array, string, or number)
  • Has required fields name and email
  • Has a name that's a string between 2-100 characters
  • Has a valid email format
  • Has an optional age that's an integer between 0-150
  • Has an optional isActive that's a boolean

Valid JSON data would be:

{
  "name": "Alice Smith",
  "email": "alice@example.com",
  "age": 28,
  "isActive": true
}

Common Schema Keywords

KeywordDescriptionExample
typeData type constraint"string", "number", "object"
requiredList of required properties["name", "email"]
minimum / maximumNumeric range{"minimum": 0, "maximum": 150}
minLength / maxLengthString length range{"minLength": 2, "maxLength": 100}
patternRegex pattern for strings"^[a-zA-Z]+$"
enumList of allowed values["active", "inactive"]
formatSemantic format validation"email", "date", "uri"
additionalPropertiesAllow extra propertiesfalse (disallow extras)

Validating Arrays

You can also validate arrays and their items:

{
  "type": "array",
  "minItems": 1,
  "maxItems": 10,
  "uniqueItems": true,
  "items": {
    "type": "string",
    "pattern": "^[a-z]+$"
  }
}

This validates an array of 1-10 unique lowercase strings.

Using OneOf / AnyOf / AllOf

JSON Schema supports conditional validation for complex scenarios:

{
  "oneOf": [
    { "type": "string" },
    { "type": "number" }
  ]
}

This allows either a string or a number, but not both and not any other type.

Real-World Use Cases

  1. API Request Validation — Ensure incoming API requests match expected formats before processing
  2. Contract Testing — Define API contracts with JSON Schema and validate responses automatically
  3. Configuration Files — Validate JSON config files against a schema to catch typos and missing fields
  4. Data Migration — Verify that migrated data conforms to the new schema
  5. Documentation Generation — JSON Schema can generate API documentation automatically

Auto-Generating Schema from JSON

Don't want to write schemas by hand? Use our JSON Schema Generator. Just paste your JSON data and it will automatically create the corresponding schema.

Try Both Tools for Free: