TXT · Text & Data tools

JSON Schema Generator

Schema title
Sample JSON
Inferred JSON Schema
9properties4levels deep869chars

Inferring a schema from an example

Paste a JSON document and the generator walks its structure, assigning a type to every value: string, number, integer, boolean, null, array, or object. Nested objects and arrays are inferred recursively, so a deeply nested API response produces a matching nested schema.

Arrays of objects

When an array contains multiple objects, the generator compares their shapes instead of only reading the first item. Properties that appear in every item become required; properties that only appear in some items still show up under properties, just not in the required list. A review array where only some entries include a comment field ends up with comment as optional and user/rating as required.

Mixed-type arrays

An array like [1, 2, 3.5] widens to {"type": "number"} for its items, since a whole number satisfies both integer and number. An array mixing unrelated types, like numbers and strings, produces an anyOf list instead of picking one type arbitrarily.

Required fields toggle

By default, every property found in the sample is marked required, since the sample is the only signal the generator has. Turn off “Mark existing fields as required” when the sample is incomplete and the schema should treat every field as optional instead.

Frequently Asked Questions

A JSON Schema document (draft 2020-12) describing the structure of the pasted JSON: property types, nested objects, array item types, and which fields are marked required.

Every item in an array is inspected individually. If all items share the same shape, the array gets one items schema. If an array of objects has fields that only appear in some items, those fields are left out of required while still appearing in properties. If items have genuinely different types, such as a mix of strings and numbers, the schema uses anyOf to list each one.

Whole numbers like 5 are inferred as integer, while decimal values like 5.5 are inferred as number. If an array mixes both, the schema widens the whole array to number, since integer is already a subset of number.

Yes. Uncheck 'Mark existing fields as required' to generate a schema where every property is optional, which is useful when the sample document doesn't include every field a real record might have.

Explore Our Tools

Browse all tools