JSON to JSON Schema
Infer structured JSON Schemas (Draft 2020-12 and Draft-07) from single JSON payloads or multi-sample arrays. Private and client-side.
About this json to json schema
This generator inspects JSON structures and automatically infers a comprehensive JSON Schema specification conforming to JSON Schema Draft 2020-12 or Draft-07. It compiles the generated schema in real time and validates the original input data against it. All schema generation and JSON compilation run inside your local browser session without uploading sensitive data structures.
JSON Schema dialects: Draft-07 versus Draft 2020-12
JSON Schema has evolved through several published drafts with meaningful semantic changes between versions. Draft-07 introduced the if/then/else conditional keywords and readOnly/writeOnly annotations. Draft 2019-09 separated the definition keyword into $defs and introduced $recursiveRef for recursive schemas. Draft 2020-12 refined the $ref behavior to allow sibling keywords, changed prefixItems for tuple validation, renamed items to replace the array-position-specific behavior, and aligned the Schema Object more closely with the version supported by OpenAPI 3.1. Choosing the correct dialect is essential because validators that support only Draft-07 will misinterpret Draft 2020-12 $defs references and prefixItems syntax.
Schema inference methodology and its limits
Automated schema inference observes the structure of supplied sample data and generates the most specific valid schema that all samples satisfy. A single sample can only prove that a field exists and has a particular type; it cannot prove that a field is always required, that a string must match a specific pattern, that a number is bounded, or that an enum is exhaustive. When multiple sample objects are supplied, the tool identifies properties common to every object versus properties that appear in only some objects, using the required property strategy selected. Date-time and UUID format detection applies conservative pattern matching but does not replace explicit business documentation of what valid values the API accepts. It compiles the generated schema in real time and validates the original input data against it. All schema generation and JSON compilation run inside your local browser session without uploading sensitive data structures.
Worked multi-sample example
Two user objects both contain id and email, but only one contains timezone. With “present in every sample” selected, id and email become required while timezone remains optional.
An integer remains an integer, mixed integers and decimal values become numbers, and a consistently formatted email can receive format: email when format inference is enabled.
Inference is evidence, not a complete contract
A sample cannot prove every allowed enum value, numeric boundary, string length, optional field, or conditional business rule. The generator therefore exposes its assumptions instead of inventing constraints that were not observed.
Accuracy boundaries
- An empty array cannot reveal the type of future items.
- A single object cannot prove whether a property is always required.
- Format detection is limited to conservative patterns such as ISO date-time, UUID, email, URI, and IP address.
- Generated schemas should be reviewed against API documentation and additional representative samples before production use.
JSON Schema 2020-12 · Content owner: CZOA Tools · Review methodology
How to use it
- Paste one JSON value or an array containing representative objects.
- Choose a schema draft and an explicit required-property strategy.
- Generate the schema and confirm that the round-trip validation passes.
- Review inferred formats and manually add business constraints that samples cannot prove.
Frequently asked questions
How does JSON to JSON Schema use an input sample?+
The page parses one JSON value or an array of sample objects, then infers a schema with the selected draft, required-property strategy, optional format inference, additional-properties setting, and optional observed examples.
Can you show an input and its result?+
For {"id":1,"name":"Ada"}, the generated document had object type, integer id, string name, and both fields required under the default controls. The page separately reported valid source JSON, valid schema document, and a passing round-trip check.
What can a generated schema prove?+
It proves that the submitted sample conforms to the generated structural draft for the selected controls. A single sample cannot establish all allowed values, business rules, exhaustive enums, production boundaries, or whether unseen fields must be accepted.
What are the visible inference choices?+
The controls select Draft 2020-12 or Draft-07, all/none/shared required fields, format inference, additionalProperties, and observed examples. Review the generated document before relying on it because each choice changes the resulting contract draft.
