What is the JSON Schema Generator?

The JSON Schema Generator reads a sample JSON value - an API response, a config file, a webhook payload - and writes a JSON Schema that validates it. It infers the type of every field, merges an array of objects into a single item schema rather than a noisy union, derives which keys are required from the ones present in every record, and can tag string formats like date-time, email, uri and uuid. You paste data you already have; you get the schema you would otherwise hand-write clause by clause.
Writing a schema by hand is slow and easy to get subtly wrong. It is tempting to type what you think a payload contains, miss a nested field, mark an occasionally-null property as required, or forget that one endpoint returns an array where another returns a single object. A schema generated straight from real data starts from the actual shape, so the document you validate against matches what the service genuinely sends. From there you tighten constraints - patterns, enums, minimums - by hand, but the tedious scaffolding is done.
Everything runs in your browser. The inference engine is dependency-free TypeScript, not a wrapper around a hosted API, so payloads - which routinely carry tokens, emails and internal IDs - never leave the page. Choose Draft-07 or the 2020-12 dialect, add a title, toggle required-field detection, format detection and strict `additionalProperties`, then copy the schema or download it as a .json file.
The schema describes your sample rather than your intent, so treat the output as a first draft: required fields are inferred from what happens to be present, and formats are detected by pattern, so a string that looks like a date is typed as one even when it is an identifier that merely resembles one.
Here is a worked example of the JSON schema generator from JSON with more than one record. Paste [{"id":1,"email":"[email protected]","nick":"x"},{"id":2,"email":null}] and press Generate. The output is an array schema whose items have id as integer, email as ["string", "null"] and nick as string, with required set to id and email, because nick is missing from the second record. The header reads 3 properties, 2 required, depth 2, 219 bytes. That is the job of any JSON to JSON schema generator: every record you add can widen a type or drop a key from required.
How to use the JSON Schema Generator?
Paste your JSON
Drop in an API response, a fixture, or any JSON value. Load the sample first to see how nested objects, arrays of objects and string formats are handled.
Pick the dialect
Choose Draft-07 for the widest tooling support or 2020-12 for the current specification. The correct $schema URI is written onto the output for you.
Set your options
Add an optional title, decide whether to emit a required array, detect string formats, and lock objects down with additionalProperties: false for strict validation.
Generate, then copy or download
Press Generate. Review the inferred types and required fields, then copy the schema to your clipboard or download it as a .json file ready to drop into your validator.
Key Features
Draft-07 and 2020-12 output
Emit either the widely-supported Draft-07 dialect or the current 2020-12 specification. The matching $schema identifier is written onto the root so validators pick the right rules.
Smart array merging
An array of objects becomes a single items schema describing one element, not a sprawling anyOf. Keys present in every element are required; keys that appear in only some are left optional.
Required-field inference
The generator derives the required array from keys present in every object it sees, which is exactly how real paginated data behaves - some fields are always there, others are not.
String format detection
Recognises date-time, date, time, email, uri, uuid and ipv4 strings and tags them with the appropriate format keyword, giving you validation you would otherwise add by hand.
Frequently Asked Questions
Related Tools
JSON Flattener
Flatten nested JSON into single-level dot-notation keys, or unflatten dotted keys back into nested objects and arrays. Lossless round trip. 100% client-side.
JSON to Go Struct
Convert JSON into Go struct definitions with json tags. Nested objects become inline structs, arrays of objects are merged, and field names follow Go conventions. Runs client-side.
JSON to TypeScript
Generate TypeScript interfaces from any JSON sample. Infers nested types, merges arrays of objects into a single interface, marks nullable and missing keys optional, and emits clean exportable code. 100% client-side.
JSONPath Tester
Test JSONPath expressions against any JSON and see the matched values and their paths instantly. Supports wildcards, recursive descent, slices, and filters. 100% client-side.
Comments
0 comments
No comments yet. Be the first to share your thoughts!