About this tool
Create a practical JSON Schema starting point from real API responses, config files, fixtures, or example payloads before adding final validation rules by hand.
JSON Schema Generator turns a representative JSON sample into a structured schema draft for API payloads, fixtures, configuration files, and contract reviews. It is useful when you need a fast starting point before adding hand-written validation rules, descriptions, ranges, formats, or examples.
- Deduplicates repeated item schemas, widens integer and decimal samples to number, and intersects required keys across sampled object arrays.
- Controls nullable types, unobserved object keys, and conservative date, date-time, email, and URI format inference explicitly.
- Compiles every generated Draft 2020-12 schema with Ajv and revalidates the original sample locally before copy or download.
How to use JSON Schema
Paste valid JSON, choose whether observed keys should become required fields, decide how nullable values should be represented, and copy the generated Draft 2020-12 schema. Review the output against real production examples before using it in validation, tests, docs, or CI checks.
When this tool is useful
- When turning an API response sample into a JSON Schema draft for documentation or validation.
- Before creating fixtures, mocks, or contract tests from a real payload.
- When comparing whether an incoming JSON sample has a stable shape worth formalizing.
Practical tips
- Paste multiple representative array items so merged item schemas capture optional fields accurately.
- Treat generated required fields as a draft because one sample cannot prove every field is always required.
- Add format, minimum, maximum, enum, description, and examples manually when the sample alone cannot infer them.
Examples you can test
Load an example, compare the result with the expected output, then replace it with your own input.
Create schema from an API response
Example input
{"id":42,"name":"Utiloom","active":true}Expected output
Object schema with integer, string, and boolean properties
This is a quick way to start documenting a small response shape before adding descriptions and formats.
Infer array item fields
Example input
[{"name":"sessions","value":1200},{"name":"signups","value":42}]Expected output
Array schema with object item properties for name and value
Use several items when an array contains optional fields so the merged item schema is more realistic.
Validation checklist
- Confirm the sample JSON is representative of real successful and edge-case payloads.
- Review required fields manually before using the schema in production validation.
- Add business rules such as formats, ranges, enums, descriptions, and examples after generation.
- Validate the final schema with a JSON Schema validator before shipping it.