Back to Tools

JSON Schema Generator

Generate a formal JSON Schema draft from your raw data structure

Sample JSON

Get a first-draft schema from a sample object

Writing a JSON Schema by hand means listing every property, nesting objects inside objects and remembering the right type names. This generator does the repetitive part. You paste one example of your data and it produces a draft-07 schema that describes the same shape. It is best treated as a starting point that you refine, not a finished contract.

Generating a schema

  1. Paste a JSON object into the Sample JSON box. Load Complex Sample fills in a product record with strings, numbers, a list and a nested object if you want to experiment.
  2. Click Build Schema.
  3. Review the JSON Schema panel. It begins with a $schema line pointing to draft-07, a generic title of Generated Schema and a type of object.
  4. Press Copy Schema and paste it into your validator, API spec or documentation. Clear resets the box.

What the output contains

  • A properties section with one entry per key, typed as string, number, boolean or object based on the sample value.
  • Nested objects, which get their own properties section, so the structure mirrors your input.
  • Arrays, described with an items type taken from the first element of the array.
  • A required list at the top level containing every key present in your sample.

Limits you should plan around

The generator is deliberately simple, so a few behaviors matter in practice. Integers and decimals both come out as number rather than integer. The required list applies only to top-level keys, and nested objects do not receive one. For arrays, only the first item is inspected, so a list of mixed types or an empty list will not be described accurately, and an array of objects is reported with an items type of object without listing that object's fields. A null value is typed as object, which is rarely what you want. There are also no formats, patterns, minimum values or descriptions; you would add those yourself. Because the required list includes everything in the sample, optional fields will need to be removed from it manually.

Where it saves time

  • Bootstrapping a schema for a new API endpoint from a real example response.
  • Creating a validation skeleton for configuration files that users will edit.
  • Documenting the shape of a data export for a teammate who has never seen it.
  • Comparing a sample against an existing schema to spot fields that were added later.

Give the tool an object at the top level for the best result. Everything is calculated in your browser with JavaScript, and if the pasted text is not valid JSON, an error dialog appears with the parser message instead of a schema.

Related Tools


Frequently Asked Questions

Which JSON Schema version does the generator produce?
The output declares draft-07 through its $schema property, using the json-schema.org draft-07 address. There is no option to select another version, so if you need a newer draft, change that line and review the keywords by hand.
Why is every field marked as required?
The generator has only one sample to look at, so it assumes each top-level key must be present and lists them all in the required array. Delete the names of optional fields from that list before using the schema for validation.
Does it distinguish integers from decimals?
No. Any numeric value is typed as number, whether it is 5 or 49.99. If you want stricter validation, edit the type to integer in the copied schema wherever whole numbers are expected.
How does it handle arrays of objects?
It looks at the first item only and reports the items type as object without describing the inner fields. Arrays of mixed types are typed by their first element, and empty arrays default to string. Expand those parts of the schema yourself.
Can I paste a top-level array?
The tool is built around a top-level object. A top-level array will not produce a meaningful result because it reads the array indices as property names. Wrap the array in an object with a key, or generate a schema for a single element.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.