# JSON Schema Generator

Generate a JSON Schema from sample JSON. The generator infers types, required properties, array item schemas and common string formats such as date-time, email, uri and uuid, and writes a schema for draft 2020-12, 2019-09 or draft-07 that you can use to validate requests, document an API or generate forms.

## Frequently asked questions

### Which JSON Schema drafts are supported?

Draft 2020-12, the current version that OpenAPI 3.1 uses, draft 2019-09 and draft-07, which many older validators and tools still expect. The choice sets the $schema URL; the keywords the generator writes mean the same in all three.

### How are required properties decided?

A property is listed under required when it appears in every sample of that object. In an array of objects, a key that is missing from some items is left out of required. Turn the option off to write a schema without any required lists.

### Which string formats are detected?

date-time, date, time, email, uri, uuid and ipv4. A format is only added when every sample value of that property matches it, so one free-text value keeps the property a plain string. Turn detection off if you do not want format keywords.

### Does the schema distinguish integers from decimals?

Yes. A property whose samples are all whole numbers gets type integer. As soon as one sample has a fractional part, the type becomes number, which also accepts integers.

### How are arrays described?

An array gets type array and an items schema built from all of its elements together. Objects in an array are merged, so the items schema lists every key that occurs in any element, with required limited to the keys that occur in all of them.

### What happens with mixed types?

When a property holds simple values of different types, such as a string in one item and null in another, the schema lists them as a type array, for example ["string", "null"]. When objects or arrays are mixed with other types, the generator uses anyOf with one schema each.

### Does it add additionalProperties or limits?

No. A sample cannot show which extra keys are forbidden or what the real minimum and maximum are, so the generator leaves additionalProperties, minLength, maximum and similar keywords out. Add them by hand where your data needs them.

### Can I validate data with the result?

Yes. Paste the schema and your data into the JSON Schema Validator, or use it with a library such as Ajv. Check the schema first: it reflects your sample, so a field that can be missing or null in real data but not in the sample needs a small edit.

### Can I use the schema in OpenAPI?

OpenAPI 3.1 uses JSON Schema 2020-12 directly, so the generated schema can go under components/schemas after you remove the $schema line. OpenAPI 3.0 uses an older subset; there, replace type arrays with nullable.

### How large can the input be?

Up to 1,000,000 characters of JSON, nested up to 64 levels. The sample is analysed for this request only and is not stored.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad 433 tools for your AI agents through one MCP server.](https://multitaskai.com/?ref=oneclickpro)
