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
integerand numbers with a fraction becomenumber. Note that JSON9.0is read as 9, so it counts as an integer. - Strings are checked against five patterns. A date and time with a time zone (
Zor an offset such as+05:30) gets"format": "date-time", a plainYYYY-MM-DDgetsdate, something likename@domain.tldgetsemail, an http or https link getsuriand a standard UUID getsuuid. - For an object, every key goes into
properties. With the first Required option, its keys are listed inrequired.
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.
phoneabove 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 thedate-timeformat follows RFC 3339, which needs an offset. - An empty array gives
{"type": "array"}with noitems, since there is nothing to learn from. - A mixed array like
[1, "a", null]gives ananyOfof integer, string and null. - In draft 2020-12,
formatis 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?
Which JSON Schema draft does this tool generate?
How does the generator decide which fields are required?
Why is my field typed as integer instead of number?
Does the tool detect email addresses and dates?
Can I generate a schema from an array of objects?
Related guides
- Free Developer Tools That Replace a Dozen Browser Tabs Free developer tools grouped by job: format, convert, encode, generate and test. What each one does, which run on the server, and the limits to know f...
- How to Beautify CSS, HTML and XML (Online, VS Code, Prettier) Beautifying adds line breaks and indentation so minified CSS, HTML or XML is readable again. How the free formatters work, their limits, and VS Code a...
- How to Format JSON: Pretty-Print, Validate and Read Errors Paste JSON into a formatter to indent it and catch errors. The exact syntax rules, how to read an error position, and how to do it in VS Code, Python...