JSON Schema Generator
Paste a JSON sample and get a JSON Schema describing it, with types, nested objects and arrays inferred. Ready to paste into OpenAPI or a validator.
Turn an example JSON document into a JSON Schema that describes its shape: types for every property, nested objects expanded, and array item types inferred. The result is a starting point you refine, not a finished contract.
Paste some JSON...
// JSON Schema Generator: Features
From an example to a contract
Writing a schema by hand from scratch is tedious and error-prone, particularly for a deeply nested document. Generating one from a representative response gives you the structure in seconds, leaving you to add the parts that an example cannot reveal: which fields are genuinely required, what ranges and formats are valid, and which properties may be absent. That division of labour is where the time is saved.
What can and cannot be inferred
A single example tells the generator the type of every value, the shape of nested objects, and the type of array items. It cannot tell whether a field is optional, because absence is not visible in a document where the field happens to be present; the exception is an array of objects, where a key missing from some of them is left out of required. It cannot distinguish an integer that must be positive from any other integer, or a string that must be an email address from any other string. It cannot know that a null means the field is nullable rather than that this particular record has no value. Those are decisions you make.
Use a representative example
The quality of the generated schema depends entirely on the sample. A response where an optional field is missing produces a schema that does not mention it at all. An array that happens to be empty yields no item type. A record where a nullable field contains null suggests the type is null. The practical advice is to use the fullest example you have, then loosen and tighten by hand where you know the real rules.
Where the result goes
JSON Schema is the validation language used by a large ecosystem: Ajv in JavaScript, jsonschema in Python, everit and networknt in Java, and the components section of an OpenAPI document, which uses a JSON Schema dialect directly. Generating a schema from a real response and pasting it into your API specification is one of the quicker routes to documentation that matches what the service actually returns.
Why a real production response makes a better schema
The generator runs in your browser and the JSON you paste is never transmitted, stored or logged, so a real production response containing customer data is safe to use as the sample. To convert the same document into TypeScript types instead, the JSON to TypeScript tool is available in the Japanese edition, and the JSON Formatter will tidy either the input or the output.
// JSON Schema Generator: FAQ
What kind of schema does it produce?
- A JSON Schema describing the structure of the document you paste: the type of each property, the shape of nested objects, and the inferred type of array items, together with an optional title you can set. The output is formatted with the indentation you choose and ready to paste into a validator or an OpenAPI document.
How are arrays handled?
- The item schema is built from every element, not just the first. Object properties are merged, a key is listed as required only if every object has it, and values of different types become oneOf, which you will probably want to tighten by hand. An empty array gives nothing to infer from.
Should I add formats and constraints?
- Usually yes, because that is where a schema earns its keep. A string that must be an email, a date-time, a UUID or a URI can declare a format; a number can declare a minimum and maximum; a string can declare a pattern or a length. None of these can be inferred from an example, and all of them turn a shape description into real validation.
Which draft does the output target?
- The generated structure uses the core keywords that are common across recent drafts, so it works with the widely used validators without modification. If your toolchain pins a specific draft, add or adjust the schema declaration at the top to match.
How large a sample can I use?
- There is no fixed limit, but a very large document produces a very large schema and becomes slow to render. A representative record or a small array of them is more useful than a full export, because the schema describes structure rather than volume.
Is it safe to use a real production response?
- Yes. Everything runs in your browser and the document is never transmitted, stored or logged. That is the point of using a real response rather than a made-up one: the schema then reflects the actual shape, including fields you might not have thought to include.
// How to Use JSON Schema Generator
-
Paste a representative sample
Put a real JSON document into the input box, ideally the fullest example you have. A record where optional fields are populated produces a far more useful schema than one where they are missing.
-
Set a title and indentation
Give the schema a title if it will live alongside others, and choose the indentation for the output. The property count and maximum nesting depth shown underneath give a quick sense of the document's complexity.
-
Copy and refine
Copy the schema, then add what an example cannot express: which properties are required, formats such as email or date-time, and any minimum and maximum constraints. That refinement is what turns a shape description into real validation.
Category Data Formats