deftools.io Developer Tools

JSON Schema Generator

Infer a JSON Schema (Draft 2020-12) from any sample JSON. Live, configurable schema generation with format detection.

Schema stats

About this tool

JSON Schema Generator inspects a sample JSON document and produces a JSON Schema (Draft 2020-12 or draft-07) that describes its shape — types, required properties, nested objects, array items, and detected formats such as email, uuid, date-time, and uri. You can also download a matching TypeScript .d.ts type definition.

Example: pasting { "id": 42, "email": "ada@example.com", "tags": ["math"] } yields a schema with id as integer, email as string with format email, and tags as an array of strings — all three marked required.

Use it to bootstrap validation for an API payload you just received, document an undocumented endpoint by feeding it real responses, or generate TypeScript types for a JSON config without writing them by hand.

FAQ

Which draft should I pick?

Draft 2020-12 is the current standard and is what most modern validators expect. Choose draft-07 only if you are integrating with an older toolchain or library that does not yet support 2020-12.

How are array item schemas inferred?

By default the generator merges the schemas of every element in the array into one permissive item schema. Enable "tuple arrays" to instead emit a fixed-position tuple (one schema per element), which is useful when array positions are meaningful.

Why are all properties marked required?

The generator infers from a single sample, so every key it saw is treated as required. After generating, review the schema and move genuinely optional fields out of the "required" array based on your domain knowledge.

Can I trust the detected formats?

Formats like email, uuid, date-time, and uri are detected by pattern heuristics against the sample values. They are a useful starting point, but verify them — a value that happens to look like a date will be tagged "date-time" even if it is semantically something else.

How do I test a schema I just generated?

Copy the generated schema and paste it into the JSON Schema Validator alongside sample data to check that real payloads pass validation. The validator supports Draft 2020-12 and shows the exact path for every violation.

More developer tools

Copied!