Key takeaways
- A 5-field example with a nested array produces a schema with 47 lines, and it appears as soon as you paste.
- Strict mode adds additionalProperties false, lists every field as required and makes optional fields nullable, which is what OpenAI-style structured outputs expect.
- A schema built from one example describes that example. Add limits such as minimum, maxLength or enum values by hand before you rely on it.
- Everything runs in your browser. The JSON you paste is never uploaded.
How to use the JSON Schema Generator
- 1Paste a representative JSON document into the example box, or edit the sample that is already there.
- 2Tick Strict mode if the schema is for an AI model, or Mark every property as required if you want a tight validation schema.
- 3Leave Detect formats on to tag dates, emails, UUIDs and URLs, or turn it off for plain string types.
- 4Check the generated schema, then use Copy or Download schema.json.
What is a JSON Schema?
A JSON Schema is a JSON document that describes the shape of other JSON documents. It says which properties an object may have, what type each value must be, which properties are required and how items inside an array should look. The current version is draft 2020-12, which is what this tool writes.
Writing a schema by hand is slow for large payloads, so most people start from a real response. If the payload is not tidy yet, run it through the JSON formatter and validator first, because the generator needs strictly valid JSON.
How does this tool work out the schema?
It walks through your example and records the type of every value: string, integer, number, boolean, null, array or object. Whole numbers become integer and numbers with a fraction become number. If an array holds several objects, their shapes are merged, so a property that appears in every item is required and one that appears in only some items is optional.
In the sample above, the orders array has two items. Both have sku and qty, but only the second has gift. The generated schema therefore lists sku and qty as required for an order and leaves gift optional.
With Detect formats on, strings that match a known pattern get a format hint: date-time for ISO 8601 timestamps, date for plain dates, email, uuid and uri. Format checks are optional in most validators, so treat them as hints unless your validator is set to enforce them.
How do I make a JSON Schema for OpenAI, Claude or Gemini structured outputs?
Turn on Strict mode. Structured outputs make the model return JSON that matches a schema you supply, and the providers are picky about what that schema may contain. OpenAI, for example, asks for additionalProperties set to false on every object and for every property to be listed as required.
Strict mode does this for you. In the sample, the optional gift field becomes a nullable type, so the model must always return the key but may return null: the order item then has 3 required fields instead of 2. The top level must also be an object, so wrap a bare array in a property such as items.
Each provider supports a slightly different subset of JSON Schema, and the lists change. Check the current documentation for the one you use. The AI token counter shows how much room a large schema takes up in your prompt, and the same count tells you what it adds to the bill.
What does a schema from one example miss?
A single example cannot show every case. If a field is sometimes a string and sometimes a number, the tool only knows about the types it saw. An empty array gives items an empty schema because there is nothing to learn from. A value that is always 3 will be typed as integer, not as the enum or range you may really want.
Treat the output as a first draft. Feed in several examples inside one array to merge their shapes, then tighten the result by hand with keywords such as minimum, maxLength, pattern and enum. Regenerate whenever the payload changes, and compare old and new versions with the text diff tool.
Is my JSON uploaded anywhere?
No. The schema is generated by JavaScript running in your browser tab. Nothing you paste is sent to a server or stored, so it is safe to use with real API responses. Remove secrets and personal data from examples before you share a schema with others, since example values can leak into descriptions if you add them later.
Worked example
Worked example: from one response to a schema
Take this response: {"id":1042,"name":"Ada Lovelace","email":"ada@example.com","joined":"2026-03-14T09:30:00Z","orders":[{"sku":"A-100","qty":2},{"sku":"B-200","qty":1,"gift":true}]}. With the default options the tool writes a schema with 5 properties and 5 required fields. The id is typed as integer, joined gets format date-time, email gets format email and orders becomes an array of objects.
Now switch on Strict mode. Every object gets additionalProperties false, every field is required and gift changes from an optional field to ["boolean","null"]. That is the shape an AI model needs to return a complete, predictable record every time.
How JSON values map to schema types
This is how the generator reads each kind of value in your example.
| Example value | Schema output | Note |
|---|---|---|
| 42 | type: integer | Whole numbers |
| 3.14 | type: number | Any number with a fraction |
| "hello" | type: string | Format added when it matches a known pattern |
| true | type: boolean | true or false |
| null | type: null | Combined with other types when seen with them |
| [1, 2] | type: array, items: integer | Item shapes are merged |
| {"a": 1} | type: object, properties | Required list built from the example |
Frequently asked questions
Which JSON Schema version does this generator use?
It writes draft 2020-12, the current version published at json-schema.org. The $schema line at the top says so, and you can remove it with the checkbox if your tool assumes a default. Most modern validators, including Ajv, accept this draft.
What is strict mode for?
Strict mode prepares a schema for AI structured outputs. It sets additionalProperties to false on every object, marks all properties as required and makes fields that were missing in some array items nullable. It also skips the uri format, which some providers reject.
Can I generate a schema from several examples?
Yes. Put the examples in one array, and the tool merges the item shapes. Properties found in every item become required, and properties found in only some are optional. This gives a much better schema than a single record.
Why is my schema missing minimum, maxLength or enum?
An example shows one value, not the allowed range, so the tool cannot guess limits. Add keywords such as minimum, maxLength, pattern and enum yourself once you know the real rules. The result is stricter and easier for others to rely on.
Does the generator handle nested objects and arrays?
Yes, to any depth. Nested objects become nested properties, and arrays get an items schema built from all their elements. Mixed types in one array become a type list or an anyOf, depending on what was found.
Is the JSON I paste stored or sent anywhere?
No. The schema is built in your browser and nothing leaves your device. For other data helpers, see the developer tools section.
Sources
- JSON Schema: A Media Type for Describing JSON Documents (draft 2020-12)
- JSON Schema Validation: A Vocabulary for Structural Validation of JSON
- OpenAI: Structured Outputs guide
Last reviewed by the ToolsFiesta team.