JSON Schema Generator

Paste a sample of your JSON and get a JSON Schema that describes it: the type of every field, which fields are required, what sits inside each array and, optionally, string formats such as email, date-time, date, uri and uuid. Use it to start a schema you then tighten by hand.

What you enter

What you get

How it works

  1. Paste a sample JSON document. A real response from your API works best. A list of several objects is even better, because the tool merges them.
  2. Choose whether fields found in every sample object are marked required, whether to detect string formats, and whether to forbid extra properties.
  3. Pick the schema version your validator expects and add an optional title.
  4. Copy the schema or download it as a .json file.

What a schema gives you

A schema turns an unwritten agreement into something a program can check. When one system sends data to another, the receiver can validate each message against the schema and reject anything with a missing field or a text value where a number belongs, with a clear message, instead of failing later in some unrelated part of the code.

The same document doubles as documentation. A new developer can read the schema to learn what a record looks like, and tools can generate forms, mock data and typed code from it. That is why teams write schemas for API requests, configuration files and the argument lists of functions that other programs call.

Why samples are not enough

A generator can only describe what it was shown. If your sample has a status field holding the word active, the schema says status is a string; it cannot know that the only legal values are active, paused and closed. Adding an enum list for that field is a two minute edit that makes the schema far stricter.

The same goes for limits. A sample age of 34 produces a plain integer, but you probably want a minimum of 0 and a maximum of 150. Look through the draft for places where you know more than the sample shows, and add those keywords. The generated structure saves the typing; your knowledge supplies the rules.

Open and closed objects

By default a JSON Schema allows extra properties that it does not mention. That is friendly when other systems may add fields over time. Switching on the no-extra-properties option writes additionalProperties: false, so any unexpected key makes validation fail, which is better when you want to catch typos in field names.

Choose deliberately. A closed schema for a public API can break clients the day you add a new optional field, while an open schema for a configuration file lets a misspelled setting pass silently. Open for data you receive from others, closed for data you control, is a sensible starting rule.

Tips

Frequently asked questions

What is a JSON Schema?

A JSON Schema is a JSON document that describes the shape of other JSON: which fields exist, what type each one holds, which are required, and what items an array may contain. Validators use it to accept or reject data, and many tools use it to build forms or documentation.

How does the generator decide a field is required?

A field is marked required when it appears in every object it saw at that level. If you paste a list of three users and only two have a phone field, phone is left optional. With one sample object, every field in it is required.

How are mixed types handled?

When the same field holds different types across samples, the schema lists all of them. For example, a list containing 1 and "a" gives items of type ["string", "integer"]. If integers and decimals both occur, the field is simply number.

Which formats are detected?

email ([email protected]), uuid (the 8-4-4-4-12 pattern), date-time (a full timestamp with a time zone, like 2024-03-05T10:20:30Z), date (2024-03-05) and uri (anything that starts with a scheme and ://). A format is only added if every string seen for that field has it.

Is my JSON sent to a server?

No. The schema is built by code running in your browser, so your data stays on your device.

Which JSON Schema version does it write?

You can choose 2020-12, the current version, or draft-07, which many older libraries still expect. The structure of the generated keywords is the same for both.

Related: JSON formatter and validator, JSON path finder, Schema markup generator.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Free Tools

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap