DevTools Hub

Search tools

Search for a developer tool

JSON

JSON Schema Generator

Generate a JSON Schema (Draft-07 or 2020-12) from a sample JSON document.

Part of the JSON Toolkit

What this does

Paste a sample JSON document and get back a JSON Schema (Draft-07 or 2020-12) that describes its shape — types for every field, required for the properties present in the sample, and a best-effort guess at string formats like email, date-time, and uuid. It's the reverse of JSON Schema Validator: instead of checking data against a schema you already have, this writes a first-draft schema from real data, so you don't have to type every property and type by hand.

How arrays are handled

When an array's elements are all the same shape — all strings, or all objects with the same keys — the generator produces a single items schema covering all of them. If an array holds objects with slightly different keys (say, some orders have a note field and others don't), the merged schema keeps every property it saw and only marks a property required if it showed up in every element. Genuinely mixed arrays — a string next to a number, say — fall back to anyOf so the schema still matches every observed shape rather than silently picking one.

A generated schema is a starting point, not a spec

This tool can only infer rules from what's actually present in your sample — it has no way to know that age should be non-negative, or that email should reject some string that happens not to appear in your example. Treat the output as a first draft: add minimum/maximum, pattern, enum, or tighten required by hand, then confirm it does what you expect with JSON Schema Validator.

FAQ

Why is a property missing from required?

With "mark present properties as required" on, a property is only required if it appeared in every element the generator saw for that shape — one array element missing a key is enough to make it optional instead.

Why does a number come out as integer instead of number?

JSON Schema's integer type matches whole numbers; the generator uses it whenever every value it saw for that field was a whole number, and widens to number automatically if it saw even one decimal value for the same field.

Try it yourself

Once you have a schema, validate real data against it with JSON Schema Validator, or format the raw JSON first with JSON Formatter.

Related tools