How it works
The JSON Schema Generator analyzes a JSON object or array and produces a draft JSON Schema (Draft-07 or Draft-2020-12) that describes its structure β including property names, types, required fields, and example values. Use it to document an API response, generate validation schemas, produce TypeScript interface suggestions, or describe a data structure for Swagger/OpenAPI.
Writing JSON Schema by hand for large API responses is tedious. This tool infers the schema from an example JSON payload automatically β the 80% solution that covers all the structural information. You can then manually refine the generated schema to add descriptions, enum constraints, and business-rule validations.
How to use it: paste a JSON object or array (or upload a .json file). The tool traverses every property and infers its type. Multiple sample objects can be pasted and the schemas merged β this helps the generator produce more accurate required/optional field detection.
Type inference: - string, number, integer (when all samples have no decimal), boolean, null - Arrays: the element type is inferred from the array contents - Objects: nested objects generate nested schema definitions - Mixed types (string and null in different samples): produces a oneOf or type: [string, null]
Required vs. optional: when multiple sample objects are provided, properties that appear in all samples are marked required; properties that appear in some are optional.
OpenAPI 3.0 export: toggle OpenAPI mode to produce a Component Schema compatible with OpenAPI 3.0 specification.
Privacy: JSON schema inference runs in the browser.
Frequently Asked Questions
- The schema is accurate for the structural types present in the sample data. It does not infer business rules (minimum/maximum values, string patterns, enum constraints) from the sample data alone. Use the generated schema as a starting point and add constraints manually: minLength, pattern, enum, minimum, maximum.
- Paste multiple sample objects (3β5 is ideal) to help the generator distinguish required fields (present in all samples) from optional ones (present in some). With only one sample, all fields are marked required. With multiple samples, fields present in all samples are required, fields absent in any are optional.
- Yes. Paste any JSON object and the tool generates a JSON Schema for it. For the JSON Schema specification documents themselves, the official meta-schemas (draft-07, 2019-09, 2020-12) are available as references at json-schema.org.
- Draft-07 uses definitions/$ref for reusable schema components and uses items for array schemas. Draft-2020-12 uses $defs instead of definitions, prefixItems instead of items for tuple schemas, and adds new keywords like unevaluatedProperties. Choose based on your validation library's support: most widely-used libraries (AJV, jsonschema-js) support both.