JSON Schema Generator
Infer a Draft 2020-12 JSON Schema from sample structure with required presence, nullable values, arrays, mixed types, and explicit uncertainty.
Privacy: your files never leave your device. All processing happens locally in your browser.
How to use
- 1.Paste representative strict JSON and optionally enter a concise schema title.
- 2.Generate and inspect required fields, nullability, array items, anyOf branches, and open-object behavior.
- 3.Copy the schema and test positive and negative instances with a Draft 2020-12-capable production validator.
About JSON Schema Generator
JSON Schema Generator converts one strict JSON value into a readable structural schema declaring the Draft 2020-12 dialect. Paste a representative sample, add an optional title, generate, inspect, and copy. Parsing and inference stay in the current tab; the page does not upload data, run a validator, or contact a schema registry.
JSON strings, safe integers, other numbers, Booleans, and null map to their corresponding JSON Schema types. Arrays use items inferred from every observed element. Empty arrays emit an empty items schema because no element constraint can be justified. Mixed compatible numbers widen integer to number, while incompatible observed types become deterministic anyOf branches.
Objects emit type object, properties, and required. A property observed in every merged object sample is required. A property missing from at least one object is left out of required. Property names are preserved exactly, including punctuation and prototype-shaped spellings. The generator intentionally omits additionalProperties, leaving objects open because one sample cannot prove that unseen keys are forbidden.
Null combined with a directly typed schema adds null to the type array while retaining properties or items. More complex combinations use anyOf. Nested objects and arrays are inferred recursively. Duplicate equivalent branches are removed and output order is deterministic, so the same input produces stable text suitable for review and version control.
This is structural sample inference, not schema discovery. The generator does not guess format, pattern, enum, const, minimum, maximum, multipleOf, lengths, uniqueness, descriptions, defaults, examples, deprecation, readOnly, writeOnly, content encoding, references, anchors, IDs, conditional logic, unevaluated properties, or business meaning. Add them only from authoritative requirements.
The dialect URI is https://json-schema.org/draft/2020-12/schema. Validators must explicitly support that dialect, and format may be annotation-only unless the chosen implementation enables assertion behavior. Test the copied schema with the exact validator, configuration, and vocabulary used in production instead of assuming every library interprets every keyword identically.
Strict JSON is required, so comments, trailing commas, NaN, Infinity, undefined, BigInt, and JavaScript literals fail. JavaScript parses the sample number before inference; only safe integers become integer, avoiding a false exactness claim for larger rounded values. Precision-sensitive decimals and identifiers may need strings plus application validation.
Limits are 500,000 input characters, 50,000 values, 40 nesting levels, and 1,000,000 output characters. Boundary failures emit no partial schema. Eight external fixtures cover all primitives, empty and typed arrays, and merged object required fields. Additional tests cover nullable items, mixed anyOf arrays, special property names, and malformed JSON. Validate both accepted and rejected instances before publishing the result.
Methodology & sources
Parses strict JSON, recursively maps observed primitives, arrays and objects to Draft 2020-12 keywords, merges object presence into required, widens integer to number, represents incompatible evidence with anyOf, preserves nullability, leaves additionalProperties unspecified, and fails instead of truncating.
Frequently asked questions
- Why is additionalProperties absent?
- One sample cannot prove that unobserved keys are forbidden. The generated object remains open until your authoritative contract says otherwise.
- Why are formats and enums not inferred?
- A spelling or small sample is insufficient evidence for semantic constraints. Add them manually from documented requirements.
- Does Draft 2020-12 guarantee format validation?
- No. Format can be annotation-only depending on vocabulary and validator configuration. Verify the exact implementation you deploy.
Related tools
- JSON ValidatorCheck if JSON is valid, pinpoint syntax errors by line and column, and see a structure diagnostic, in-browser.
- JSON FormatterFormat, minify, and validate JSON in your browser β pretty-print or compress with pinpoint error locations.
- JSON to Zod Schema ConverterInfer a reviewable Zod schema from one JSON sample, including nested objects, arrays, unions, nullable values, and optional merged fields.
- JSON to Rust Struct ConverterInfer reviewable Serde Rust structs from JSON, including nested objects, vectors, optional fields, nulls, renames, and normalized identifier collisions.
- ANSI Color Codes GeneratorBuild and copy raw SGR escape sequences and search the standard 8 plus bright 8 terminal color codes.
- ASCII TableLook up every standard 7-bit ASCII code with exact decimal, hexadecimal, octal, and binary values.
Developer Tools guides
View all- How to Get a CSS Loader With a Visual Generator
- Make a CSS Grid in Minutes with a Live Generator
- Create a Linear Gradient in Canva Using CSS Gradient Generator
- Convert a Cake Recipe to Cookies Using a Cookie to JSON Tool
- Create Glassmorphism Effects in CSS with a Visual Generator
- Design Custom CSS Shapes with a Free Clip Path Generator
- Create a 3D Button in CSS with a Visual Generator
- How to Get a Box Shadow in CSS with a Visual Generator
- Border Radius Generator Online: Copy the Shortest CSS Declaration
- Parse a Cron Expression and See Next Run Times Instantly
- How to View the Clipboard and Inspect Hidden Text Details
- How to Get Badge Elevators in NBA 2K25 Using a Badge Generator
- How to Generate Code Image From Text Locally
- Calculate Chmod Values Quickly Using Octal and Symbolic Notation
- Remove BOM from CSV Files Without Losing Data
- How to Use ASCII Codes in C++ for Character Handling
- Build a Cron Job Schedule Without Memorizing Field Order
- How to Create Flexbox in CSS: A Practical Walkthrough
- Create a Dummy File in CMD with Exact Size and Content
- How to Create a Directory Tree in CMD: A Practical Walkthrough