Resell services with the EthicalSMM API

JSON Schema Generator

Generate a JSON Schema (draft 2020-12) from sample JSON, with types, required fields and formats such as email, date and URI detected.

Was this tool helpful?

Thanks for the feedback!

This tool reads sample JSON and writes a JSON Schema (draft 2020-12) that describes it: the type of every field, which fields are required and common string formats such as email, date and URI. It gives developers a solid first draft for API documentation, request validation or form generation, which you then tighten by hand. Everything runs in your browser.

The fields

Paste a JSON document or, better, an array of several sample records into the main box. Schema title sets the title keyword and defaults to "Generated schema". Required fields has two choices: "Mark keys present in every sample as required" or "Make nothing required".

How the schema is inferred

  • null, true/false, objects and arrays get the matching type.
  • Whole numbers become integer and numbers with a fraction become number. Note that JSON 9.0 is read as 9, so it counts as an integer.
  • Strings are checked against five patterns. A date and time with a time zone (Z or an offset such as +05:30) gets "format": "date-time", a plain YYYY-MM-DD gets date, something like name@domain.tld gets email, an http or https link gets uri and a standard UUID gets uuid.
  • For an object, every key goes into properties. With the first Required option, its keys are listed in required.

Arrays are where the tool earns its keep. It infers a schema for every item and merges them. Objects are merged by combining their properties, and only keys found in every item stay required. An integer merged with a number becomes number. Two strings with different formats become a plain string. Any other mix, such as numbers and text in one array, becomes an anyOf list.

Worked example

Input with title "Customer":

[{"id":1,"email":"asha@example.in","joined":"2026-01-15","site":"https://example.in","score":8.5},
 {"id":2,"email":"ravi@example.com","joined":"2026-02-01","score":9,"phone":null}]

The tool returns "type": "array" with this items schema:

"items": {
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "email": { "type": "string", "format": "email" },
    "joined": { "type": "string", "format": "date" },
    "site": { "type": "string", "format": "uri" },
    "score": { "type": "number" },
    "phone": { "type": "null" }
  },
  "required": ["id", "email", "joined", "score"]
}

The real output is indented over more lines, but the content is the same. score is a number because 8.5 and 9 were merged. site and phone appear in only one record, so they are not required.

What to check before you use it

  • The schema only knows your samples. phone above was always null, so it got "type": "null". In practice you would change that to ["string", "null"]. Paste more varied records for a better guess.
  • A date-time without a time zone, such as 2026-12-04T10:30:00, is left as a plain string, because the date-time format follows RFC 3339, which needs an offset.
  • An empty array gives {"type": "array"} with no items, since there is nothing to learn from.
  • A mixed array like [1, "a", null] gives an anyOf of integer, string and null.
  • In draft 2020-12, format is an annotation by default. Many validators only enforce it when you switch format checking on.

The tool does not add limits such as minLength, maximum or enum, or additionalProperties. Add those yourself where your data needs them.

Related tools

A good routine is to collect a handful of real records, including unusual ones with missing or empty fields, generate the schema from all of them together, and then read it line by line against what the data is meant to allow. The result can go into API documentation or a validator in your test suite.

To get TypeScript interfaces from the same sample, use JSON to TypeScript. To check that a sample is valid JSON before you start, use the JSON validator.

Frequently asked questions

What is a JSON Schema?
A JSON Schema is a JSON document that describes the shape of other JSON: which keys exist, their types, which are required and any formats or limits. Validators use it to check data automatically.
Which JSON Schema draft does this tool generate?
It writes draft 2020-12 and sets $schema to https://json-schema.org/draft/2020-12/schema at the top of the output.
How does the generator decide which fields are required?
With the default option, a key is required only if it appears in every sample object. Choose Make nothing required if you want every property to be optional.
Why is my field typed as integer instead of number?
All the samples for that field were whole numbers. Add a sample with a fraction, such as 8.5, and the merged type becomes number, or edit the schema by hand.
Does the tool detect email addresses and dates?
Yes. It adds a format for email addresses, YYYY-MM-DD dates, date-times with a time zone, http and https links and UUIDs.
Can I generate a schema from an array of objects?
Yes, and it gives better results than a single object. The tool merges every item, combines their properties and marks as required only the keys found in all of them.

Related guides

Related tools

People also used

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.