JSON Schema Validator
Validation Results
No validation yet.
JSON Schema Validator & Generator
The JSON Schema Validator checks whether your JSON matches a defined schema so you can enforce structure, types, and required fields with confidence. It is ideal for API payloads, configuration files, and data pipelines where consistency matters. Paste your JSON and a schema, run validation, and you will instantly see errors with clear paths to the failing fields. The tool runs entirely in the browser, so your data stays private and is never uploaded.
JSON Schema defines the shape of your data: which keys are allowed, which fields are required, the types of values, and constraints such as minimum lengths or numeric ranges. By validating against a schema, you prevent subtle production bugs and protect downstream services from malformed data. This is especially useful in teams where multiple systems exchange JSON and you need a single source of truth for data contracts.
What JSON Schema validation checks
- Types: Ensure each property is the correct type (string, number, object, array, boolean, or null).
- Required fields: Guarantee mandatory keys are present.
- Value rules: Enforce min/max length, enum choices, numeric ranges, and regex patterns.
- Object structure: Limit additional properties or specify nested schemas.
- Array rules: Validate item types, length, and uniqueness.
How to use this validator
- Paste the JSON data in the left editor.
- Paste your JSON Schema in the right editor.
- Click Validate to see a success message or detailed errors.
- Use Generate Schema if you want to create a schema from a sample JSON payload.
Example schema and JSON
Schema (Draft-07 style):
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["id", "email", "roles"],
"properties": {
"id": { "type": "integer", "minimum": 1 },
"email": { "type": "string", "format": "email" },
"roles": {
"type": "array",
"items": { "type": "string", "enum": ["admin", "editor", "viewer"] },
"minItems": 1
},
"profile": {
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 2 },
"active": { "type": "boolean" }
},
"additionalProperties": false
}
},
"additionalProperties": false
}
Valid JSON input:
{
"id": 10,
"email": "hello@example.com",
"roles": ["editor"],
"profile": { "name": "Avi", "active": true }
}
Invalid JSON input (fails multiple rules):
{
"id": 0,
"email": "not-an-email",
"roles": [],
"profile": { "name": "A", "active": "yes" },
"extra": "not allowed"
}
Common errors and how to fix them
- Missing required field: If validation says a required property is missing, add it to your JSON or remove it from
requiredif optional. - Type mismatch: A string where a number is expected will fail. Update the JSON value or adjust the schema type.
- Format error: Formats like
email,date-time, orurimust match standard patterns. Fix the value to follow the format. - Additional properties not allowed: If
additionalPropertiesisfalse, remove unknown keys or add them to the schema. - Enum violation: Values must be one of the schema's allowed list. Update the value or extend the
enum. - Array constraints: Arrays can fail on
minItems,maxItems, or invalid item types. Adjust the array or schema. - Minimum or maximum limits: Numeric ranges or string lengths may be too strict. Revisit
minLength,maxLength,minimum, ormaximum.
Best practices for strong schemas
- Use
requiredfor fields that must always exist. Keep optional fields out of the list. - Set
additionalPropertiestofalsefor strict APIs, or allow it when flexibility matters. - Document your schema with
descriptionto help teammates understand the intent. - Validate early in your pipeline to catch issues before storing or forwarding data.
- Use the JSON Schema Builder to scaffold schemas faster.
Schema design tips for real-world APIs
Start with a minimal schema that reflects the most important contract. Add constraints gradually as your payload stabilizes. This prevents over-restrictive schemas that block legitimate data. Use oneOf or anyOf when a field can have multiple shapes, and add description and examples to improve readability for your team.
For configuration files, consider making unknown keys illegal to avoid silent misconfigurations. For public APIs, allow unknown keys when you want backward compatibility and faster iteration. Always test schema changes with sample payloads from production to avoid breaking consumers.
Validation workflow checklist
- Validate JSON syntax first with JSON Validator.
- Validate against the schema and review every error path.
- Fix errors in the data or update the schema if the rule is incorrect.
- Re-run validation after changes.
- Store the schema alongside code or docs for future reference.
Key schema keywords to know
Understanding a few core keywords will cover most validation use cases. type defines the data type, properties describes object fields, and items defines array element rules. Use minLength and maxLength for strings, minimum and maximum for numbers, and enum for fixed value lists. For objects, required enforces mandatory keys, and additionalProperties controls whether extra fields are allowed.
When you need conditional logic, oneOf or anyOf lets you accept multiple shapes. Use them sparingly to keep schemas understandable. A simple, readable schema is easier to maintain and debug than a complex one.
FAQs
Which JSON Schema draft is supported?
Most rules follow Draft-07 style, which covers common validation needs for APIs and configs.
Does validation modify my JSON?
No. The validator only checks your input and reports issues.
Why is my JSON valid but schema validation fails?
Syntax validity and schema validity are different. A JSON can be syntactically valid but violate schema rules like types or required fields.
Can I validate arrays or nested objects?
Yes. JSON Schema supports nested rules and array item definitions.
What if I need custom error messages?
Use description in your schema or adjust your schema to be more precise; this tool reports the failing path and rule.
Is my data private?
Yes. Validation happens locally in your browser.
How can I generate a schema quickly?
Try the JSON Schema Builder or start from a sample and edit as needed.
Can I validate large JSON files?
Yes, but very large inputs may be slower. Consider validating smaller samples during development.
Can I reuse schemas across services?
Yes. Shared schemas are a great way to keep multiple services consistent.
What should I do if my schema is too strict?
Relax constraints, allow additional properties, or expand enums to cover real values.
Related tools: JSON Validator, JSON Formatter, JSON Schema Builder, JSON Model Generator