JSON Schema Generator

Generate a JSON Schema from an example JSON document

Turn an example JSON document into a JSON Schema (draft 2020-12 or draft-07): types, nested objects, array item schemas, required fields and formats such as email, date-time and uri are detected automatically. A quick start for API validation and documentation.
Try an example:

Output will appear here...

About JSON Schema Generator

How it works

  1. Each value in your example becomes a schema: strings, integers, numbers, booleans, null, objects (with their properties) and arrays (with an items schema).
  2. When an array holds several objects, their schemas are merged: every property seen is included, but only properties present in all items are required. Mixed types become a list of types, such as ["string", "null"].
  3. Strings are checked against common formats - email, date-time, date, time, uri, uuid and IPv4 - when detection is on.
  4. The result starts with the $schema keyword for the version you choose, so validators know how to read it.

What you need

  • A representative example of the JSON you want to describe. The more varied the example (optional fields, nulls), the better the schema.

Tips

  • Use a few array items that show optional fields, so they are correctly marked as not required.
  • Review the result: an example cannot tell the generator about allowed ranges, enums or patterns - add minimum, maximum, enum and pattern yourself.
  • Draft-07 is supported by the most tools; 2020-12 is the latest standard and what OpenAPI 3.1 uses.

Limitations

  • The schema reflects only the example you give; it may be too strict or too loose for real data.
  • Formats are detected by pattern and may occasionally misfire (for example a string that only looks like a date).

Runs in your browser. Everything happens in your browser - your code and data are never uploaded.

Frequently asked questions

What is JSON Schema?+

A standard way to describe the shape of JSON data - which properties exist, their types and which are required. Validators use it to check data, and tools use it to generate forms, documentation and code.

Which draft should I choose?+

Draft 2020-12 is the current version and is used by OpenAPI 3.1. Draft-07 is older but supported by almost every validator and editor. If unsure, pick draft-07 for compatibility.

Why is a property marked as required?+

It appeared in every object of your example. If it is really optional, include an example object without it, or choose "None" for required properties.