About the JSON Schema Generator
A JSON Schema describes what a document must look like, and writing one from scratch is slow. This generator infers a starting point from a sample: every object becomes a schema of type object with a properties map and a required list containing all its keys, every array becomes an array schema whose items follow the first element, and primitives get their type with integer distinguished from number.
The result targets draft 2020-12 and includes the $schema keyword. It is intentionally strict: all present keys are required and types are exact. Loosen it where the real contract allows, for example by removing keys from required, adding null to a type array, or replacing an empty items with a real schema for arrays that were empty in the sample.
Formats, enums, minimums and patterns are not inferred because a single sample cannot justify them. Once edited, validate documents against the schema in your language of choice; every major ecosystem has a validator for 2020-12.
How to use
- Paste a representative JSON document on the left.
- Copy the schema from the right.
- Edit required lists and types to match the real contract, then use it in your validator.
Common questions
- Which JSON Schema draft is generated?
- Draft 2020-12, the current version. Most validators also accept it as draft 7 with minor changes.
- Why is every field required?
- A sample shows only fields that are present, so the safest inference is that they are required. Remove names from the required array for optional fields.
- Does it infer enums or formats?
- No. One sample cannot show the set of allowed values or a date format; add those by hand.