ToolJutsu
All tools
Developer Tools

JSON Schema Generator

Infer a JSON Schema from a sample document.

0 B
Tip: press Ctrl/ + Enter

The schema is inferred from one example, so it reflects only the fields and types present in your sample. Treat it as a starting point — add formats, constraints and descriptions to suit your real data.

Processed on your device. We never see your files.

How to use JSON Schema Generator

What this tool does

This tool reads a sample JSON document and infers a JSON Schema that describes its shape. It walks the value recursively: objects become a properties map with a required list, arrays get an items schema, and scalars are classified as string, number, integer, boolean or null. The result is a draft-07 schema, declared with the standard $schema keyword, that you can drop straight into a validator. The inference runs entirely in your browser — your sample is never uploaded.

Why you might need it

Writing a JSON Schema by hand is tedious, especially for a large or deeply nested payload. If you already have a representative example — an API response, a config file, a fixture — it is much faster to generate a schema from it and then refine. A schema is useful for validating incoming data before you trust it, documenting the contract of an API, generating typed code in languages that support it, and catching regressions when a payload silently changes shape. Even as a one-off, generating a schema is a quick way to get a precise, machine-readable description of what a JSON document actually contains.

How to use it

  1. Paste a representative JSON document into the input box, or drop a .json file.
  2. Click Generate schema, or press Ctrl/Cmd + Enter.
  3. The inferred draft-07 schema appears below as pretty-printed JSON.
  4. Copy it with the copy button and paste it into your validator or repo.
  5. Refine the result — add formats, ranges, patterns and descriptions by hand.

The Load sample button provides a JSON document with nested objects and arrays so you can see how the inference handles each structure.

How inference works

For an object, every key becomes an entry in properties, and every key present in the sample is added to required — because the tool only sees one example, it assumes everything it saw is mandatory. For an array, the tool infers a schema for each element and merges them into a single items schema; when elements disagree, the type becomes a list of all observed types and object properties are combined. An empty array produces { "type": "array" } with no items, since there is nothing to infer from. Numbers split into integer (no fractional part) and number, and null is reported as the null type.

Common pitfalls

The biggest limitation is that a schema can only describe what the sample showed. If a field is optional in real life but present in your example, it will be marked required. If a field is sometimes a string and sometimes null, but your sample only had the string, the schema will not allow null. Give the richest, most representative example you can — ideally an array containing several varied objects — so the merge logic sees the real range of values. Also remember the tool cannot infer semantic rules: a date string is just a string, an email is just a string, and a value capped at 100 has no maximum. Add those constraints yourself.

Tips and advanced use

To get a schema that tolerates real-world variation, feed the tool an array of several example objects rather than a single one — the per-element merge will widen type lists and relax the required set automatically. Once you have the draft, layer on format (for dates, emails, URIs), enum for fixed value sets, and minimum/maximum or pattern where they apply. Because the whole process is client-side, you can safely generate a schema from production data; none of it leaves your browser.

Frequently asked questions

Is my JSON sent to a server?
No. The schema is inferred from your sample entirely inside your browser using JavaScript. Nothing is uploaded, so it is safe to generate a schema from a document that contains real or sensitive data.
Which JSON Schema version does it produce?
It produces draft-07, declared with the standard $schema keyword pointing at the draft-07 meta-schema. Draft-07 is widely supported by validators, editors and code generators across most languages.
Why are integers and numbers treated differently?
A value with no fractional part, such as 5, is inferred as integer; a value like 5.5 is inferred as number. If a field can hold both, give a sample where that field varies and the schema will list both types.
How does it handle arrays where items differ?
It infers a schema for each element and merges them. If the elements are objects with different keys, properties are combined and only keys present in every element are marked required.
Will the generated schema be complete?
It captures structure and types from one example, which is a strong starting point, but it cannot infer rules it never saw — formats, value ranges, patterns or enums. Treat the output as a draft and refine it for your real data.

Related tools