What you can do with JSON Schema Generator & Validator
- Generate json schema from json
- Validate json against schema
How this data and SQL utility works
Infer a JSON Schema Draft-07 contract from one JSON value or multiple sample records, and validate a JSON document against a supplied Draft-07 schema.
Example input
[{"userId":"usr_1","email":"[email protected]","age":29},{"userId":"usr_2","email":"[email protected]","tags":["admin"]}]Example output
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Inferred Schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"userId": {
"type": "string"
},
"email": {
"type": "string"
},
"age": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"userId",
"email"
]
}
}Practical workflow
- Paste one JSON value or an array of representative records into the inferrer.
- Review the generated Draft-07 schema; for arrays of objects, properties missing from some records remain optional.
- Switch to Schema Validator, enter a JSON document and a Draft-07 schema, and read all reported constraint errors.
- Copy the inferred schema when you are ready to use it in your application.
Common use cases
- Defining strict API validation contracts for backend microservices.
- Configuring OpenAPI/Swagger request body schema definitions.
- Generating automated test data mockers and contract tests.
Important notes and limitations
- The inferrer merges object properties across sample arrays, marks only common properties required, and preserves mixed value types with anyOf.
- The validator uses Ajv with standard formats and reports every detected constraint error with its JSON Pointer path.
- Generation and validation support JSON Schema Draft-07 only. Validation is local and does not fetch remote $ref documents.
- Each JSON document or schema is limited to 1,000,000 characters to keep parsing and validation work bounded in the browser.
JSON Schema validation & CLI schema generators
Validate JSON against schema with ajv-cli
npx -y ajv-cli validate -s schema.json -d data.jsonValidates data files against Draft-07 or Draft 2020-12 JSON Schema specifications with detailed error output.
Infer JSON Schema from sample JSON payload
npx -y quicktype --src sample.json --src-lang json --lang schema -o schema.jsonInfers property types, required arrays, and nested object definitions directly from sample data.
Ajv validation & draft version troubleshooting
strict mode: unknown keyword '...' (Schema compilation error)
Cause: Using Draft-04 keywords inside Draft 2020-12 schema or mixing unrecognized custom validator attributes.
Solution: Specify the correct '$schema' URI (e.g. 'https://json-schema.org/draft/2020-12/schema') and verify schema compliance.
Additional properties allowed unintentionally
Cause: Omission of '"additionalProperties": false' at root and nested object schema levels.
Solution: Explicitly declare 'additionalProperties: false' to reject payload tampering and unrecognized keys.
Continue your workflow
- JSON to TypeScript — generate TypeScript interfaces and Zod schemas from JSON.
- JSON Formatter — format, indent, and validate raw JSON syntax.
Frequently asked questions
Which JSON Schema draft specifications are supported by the generator?
The inferrer generates Draft-07 schemas. The validator supports Draft-07; Draft 2019-09 and Draft 2020-12 schemas are not supported by this tool.
How are optional properties determined from sample payloads?
For an array of sample objects, the inferrer merges their properties. A property is listed in required only when it appears in every object in the array.
Can I validate an incoming JSON payload against my schema?
Yes. Switch to Schema Validator and provide both texts. Ajv checks the document against Draft-07 constraints such as type, required, enum, bounds, patterns, and standard formats, then lists all failures with their paths.