🔒 Processed locally in your browser — no data uploaded
← Back to Home

JSON Schema Generator

Paste Sample JSON
JSON Schema

What the JSON Schema Generator does

JSON Schema Generator reads one sample document and writes a draft-07 schema describing its shape. Object keys become properties, values decide the types, and every key whose value is not null is listed in the root required array. A sample object captured from an API, a config file or a fixture is enough to start a contract for validation, documentation or a tool that expects a schema.

Paste {"name":"John","age":30,"tags":["dev"]} and the output is a schema with type object, a properties entry for each key, age typed as integer, tags as an array whose items are strings, and required holding name, age and tags. The stats line reports how many properties were found and how many required entries were written.

How to use it

  1. Paste one sample objectThe box is prefilled with a realistic example and a schema is generated on page load, so you see the output shape before pasting your own data. Any valid JSON value works as a source.
  2. Press Generate SchemaThe sample is parsed and walked recursively. Each value is typed as object, array, string, integer, number, boolean or null, and a draft-07 schema object is printed into the panel below.
  3. Read the required listTop-level keys that held a non-null value appear in required. A key whose sample value was null still becomes a property, but stays out of required, because the sample says nothing about it.
  4. Copy the schema outSelect the printed text and copy it into your editor. There is no download button, so keep select-all in mind for schemas longer than the visible area of the panel.

Options and formats

Sample input boxTakes a single JSON value: object, array or scalar. Arrays are described from their first element, so put the most representative item first when the array holds mixed shapes.
Generate Schema buttonRe-runs inference from whatever is in the box and replaces the previous result. Press it after every edit to the sample instead of assuming the panel refreshed itself.
Required arrayLists each top-level key whose value was present and not null. Keys are added in the order they appear in the object, and the array is omitted completely when no key qualifies.
Stats lineCounts top-level properties and required entries from the last successful generation. It is a quick sanity check that the sample you pasted is the one you meant to describe.

Things to watch out for

Nested objects get no requiredOnly the root object receives a required array. Objects inside it are described with type and properties but no required list, so treat the output as a first draft and add nested requirements by hand where they matter.
Arrays infer from item oneAn array is described entirely from its first element. A list holding a string, then a number, then an object becomes an array of strings, and an empty array becomes an array with an empty items rule that accepts anything.
Types are not formatsEvery string is typed as string, so email addresses, dates, UUIDs and URLs get no format keyword, and numbers get no minimum, maximum or multipleOf. Add those constraints manually; inference only reports the container type.
Required means seen in this sampleBeing in required only says the key had a value in your example, not that the API always sends it. Move fields that are sometimes absent out of required before you use the schema to reject real payloads.

Frequently asked questions

Which draft does the output target?

The schema declares draft-07 in its $schema line, the version most validators and code generators accept today. Keywords from newer drafts, such as prefixItems or $defs, are not produced, so a 2020-12-only validator may need small edits.

How are integers and decimals treated?

A whole number such as 30 becomes integer, and a fractional value such as 95.5 becomes number. Both are inferred from the JSON text, so a value written as 30.0 arrives as number rather than being rounded into an integer.

Do false and zero count as required?

Yes. The check is only for null and undefined, so isAdmin false and count 0 are both present values and both land in required. Only an explicit null leaves a key out of that array while it still appears under properties.

Can I merge several samples into one schema?

No. Inference works from the single document in the box. To cover optional fields and variants, generate once per sample and merge the properties and required lists yourself, or paste one document that contains every field you care about.

Does it validate data against the schema?

No. It only writes a schema from an example. Nothing is checked against the result, so a field missing from your sample simply never appears in the output. Use a separate validator when you want to test real payloads.

What about a top-level array or scalar?

A scalar is typed on its own, so pasting 42 returns a schema of type integer, and a top-level array is described from its first element. Neither form produces a required array, and most APIs expect an object at the root anyway.