# JSON Schema Validator

Validate JSON data against a JSON Schema to verify structure and data types

> Canonical page: https://elysiatools.com/en/tools/json-schema-validator

- **Category:** Validation

- **Keywords:** json, schema, validator, validation, structure, data, format

## Overview

# JSON Schema Validator

## Overview

JSON Schema Validator is a powerful tool for validating JSON data against predefined schemas. It ensures that your JSON data conforms to expected structures, data types, and constraints.

## Features

### Supported JSON Schema Keywords

- **type**: Validate data type (string, number, integer, boolean, array, object, null)
- **properties**: Define object property schemas
- **required**: Specify required object properties
- **additionalProperties**: Control whether extra properties are allowed
- **items**: Define array item schemas (single schema or tuple validation)
- **minItems / maxItems**: Set array length constraints
- **uniqueItems**: Require all array items to be unique
- **enum**: Restrict values to a specific set
- **const**: Require an exact constant value
- **minimum / maximum**: Set numeric range constraints
- **exclusiveMinimum / exclusiveMaximum**: Exclusive numeric bounds
- **multipleOf**: Require values to be multiples of a number
- **minLength / maxLength**: Set string length constraints
- **pattern**: Validate strings against regex patterns
- **format**: Validate built-in formats (email, uri, etc.)
- **allOf**: Data must match all sub-schemas
- **anyOf**: Data must match at least one sub-schema
- **oneOf**: Data must match exactly one sub-schema
- **$ref**: Reference another schema (basic support)

## Example Usage

### Basic Object Validation

**JSON Data:**
```json
{
  "name": "John Doe",
  "age": 30,
  "email": "john@example.com"
}
```

**JSON Schema:**
```json
{
  "type": "object",
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "age": { "type": "integer", "minimum": 0, "maximum": 150 },
    "email": { "type": "string", "format": "email" }
  },
  "required": ["name", "age"]
}
```

### Array Validation

**JSON Data:**
```json
{
  "tags": ["javascript", "typescript", "vue"]
}
```

**JSON Schema:**
```json
{
  "type": "object",
  "properties": {
    "tags": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 1,
      "uniqueItems": true
    }
  }
}
```

### Nested Object Validation

**JSON Data:**
```json
{
  "user": {
    "id": 123,
    "profile": {
      "firstName": "Jane",
      "lastName": "Smith"
    }
  }
}
```

**JSON Schema:**
```json
{
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "id": { "type": "integer" },
        "profile": {
          "type": "object",
          "properties": {
            "firstName": { "type": "string" },
            "lastName": { "type": "string" }
          },
          "required": ["firstName", "lastName"]
        }
      },
      "required": ["id", "profile"]
    }
  }
}
```

## Common Validation Errors

| Error | Cause | Solution |
|-------|--------|----------|
| Missing required field | Required property not found | Add the missing property |
| Expected type X, got Y | Data type mismatch | Correct the data type |
| Additional property not allowed | Extra property when `additionalProperties: false` | Remove extra property or allow it |
| String does not match pattern | Regex pattern validation failed | Update string to match pattern |
| Array must have at least X items | Array too short | Add more items or adjust minItems |
| Value must be one of | enum constraint failed | Use one of the allowed values |

## Supported JSON Schema Versions

- draft-04
- draft-06
- draft-07
- 2019-09
- 2020-12

## Tips for Writing Effective Schemas

1. **Use descriptive property names** - Makes validation errors clearer
2. **Set appropriate constraints** - Balance flexibility with strictness
3. **Document your schemas** - Use `description` and `title` fields
4. **Test edge cases** - Validate with boundary values
5. **Use `additionalProperties: false`** - Catch typos in property names
6. **Leverage `required` sparingly** - Only enforce truly mandatory fields

## Inputs

- **JSON Data** (textarea): Enter JSON data to validate (e.g., {"name": "John", "age": 30})...
- **JSON Schema** (textarea): Enter JSON Schema (e.g., {"type": "object", "properties": {...}})...

## When to use

- When debugging API payloads to ensure they match the expected request or response structure.
- When writing or testing a new JSON Schema draft to verify it correctly flags invalid data.
- When validating configuration files or mock data against strict structural constraints before deployment.

## How it works

- Paste your raw JSON data into the JSON Data input field.
- Enter your JSON Schema defining the expected structure, types, and constraints in the JSON Schema input field.
- The validator automatically parses both inputs and runs validation rules based on the schema specifications.
- View the validation results, highlighting any structural mismatches, missing required fields, or invalid data formats.

## Use cases

- Validating user registration payloads against schema rules like email format and minimum age.
- Verifying that configuration files contain all required keys and correct value types.
- Testing array inputs to ensure they contain unique items and meet length constraints.

## Frequently asked questions

### Which JSON Schema draft versions are supported?

The validator supports Draft-04, Draft-06, Draft-07, 2019-09, and 2020-12.

### Can I restrict extra properties not defined in the schema?

Yes, set the 'additionalProperties' keyword to false in your schema to reject any undefined properties.

### How does the validator handle format validation?

It validates built-in formats like email, uri, and date-time against the specified string properties.

### What happens if my JSON is malformed?

The tool will report a syntax error indicating that the input is not valid JSON before running schema validation.

### Does this tool support external schema references ($ref)?

It provides basic support for internal and basic external references to resolve sub-schemas.

## Related tools

- [ID Card Validator](https://elysiatools.com/en/tools/id-card-validator): Validate and analyze ID card numbers from various countries with detailed breakdown
- [BSON Converter](https://elysiatools.com/en/tools/bson-converter): Encode and decode data to/from BSON (Binary JSON) format
- [CSON to JSON Converter](https://elysiatools.com/en/tools/cson-to-json): Convert CSON (CoffeeScript Object Notation) data to JSON format
- [BOM Character Remover](https://elysiatools.com/en/tools/data-bom-remover): Remove BOM (Byte Order Mark) characters from text and file content. Perfect for cleaning up text files that have encoding issues, fixing CSV imports, and preparing data for processing. Features: - Detect and remove UTF-8 BOM (EF BB BF) - Detect and remove UTF-16 BOM (FE FF or FF FE) - Detect and remove UTF-32 BOM (00 00 FE FF or FF FE 00 00) - Support multiple input formats - Visual BOM character display - Detailed detection report - Support for batch text processing Common Use Cases: - Fix CSV file import errors - Clean up text file encoding issues - Prepare data for JSON parsing - Fix XML parsing problems - Resolve API data encoding conflicts - Standardize text data format
- [EDN to JSON Converter](https://elysiatools.com/en/tools/edn-to-json): Convert EDN (Extensible Data Notation) data to JSON format
- [GraphQL to JSON Converter](https://elysiatools.com/en/tools/graphql-to-json): Convert GraphQL query or response data to JSON format
- [JSON Formatter](https://elysiatools.com/en/tools/json-formatter): Format and validate JSON data
- [JSON to CSON Converter](https://elysiatools.com/en/tools/json-to-cson): Convert JSON data to CSON (CoffeeScript Object Notation) format

## Samples

- [JSON Samples](https://elysiatools.com/en/samples/json): JSON (JavaScript Object Notation) format examples from simple to complex structures
- [Terraform Plan JSON Samples](https://elysiatools.com/en/samples/terraform-plan-json-samples): Sample Terraform plan JSON files exported from terraform show -json style payloads for dependency visualization and change review
- [Chat Transcript JSON Samples](https://elysiatools.com/en/samples/chat-transcript-json): JSON examples for multi-role chat transcripts
- [Rich Media JSON Samples](https://elysiatools.com/en/samples/rich-media-json): JSON examples for popular rich text editors (TipTap, Quill, Slate)

## Related content

- [API Contract Definition, Schema Validation, and Change Testing](https://elysiatools.com/en/hubs/api-contract-testing): Define an API contract, validate schemas and captured payloads, detect compatibility risks, and record test acceptance.
- [JSON Schema and API Contract Validation Tools](https://elysiatools.com/en/hubs/json-validate): Compare JSON schema validation, OpenAPI response checks, mutation testing, stress testing, and breaking-change detection tools in one hub for API contract review.
- [JSON Utility, Inspection, and Transformation Tools](https://elysiatools.com/en/hubs/json-utility): Format, inspect, compare, merge, transform, validate, analyze, and watermark JSON payloads for API and data workflows.
