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 Generate JSON Schema from JSON Data: Review Workflow
- How to Generate JSON Schema from a Java Class
- Generate JSON Schema From a C# Class Instance
- Set Up a JSON Schema in Visual Studio From a Sample
- Create JSON Schema in Python From a JSON Sample
- Create JSON Schema in Postman From a Response Sample
- Free CSS Speech Bubble Generator With No Sign-Up
- Neumorphism Generator Explained: Shadows, Color, and CSS
- CSS Loader Generator for Beginners: Settings to Status
- CSS Grid Generator Example: Equal Tracks and Gaps
- How to Make a Linear Gradient in Photoshop
- Glassmorphism Generator Explained: Design and Validation
- Clip Path Generator for Large Text: Polygon CSS
- How to Make Square Button CSS: Sharp Corners or Sides
- Box Shadow Generator for Large Text: CSS Workflow
- Border Radius Generator: No Sign-Up Required
- Cron Expression Generator Alternative: Compare by Task
- Cookie Converter on Android: Strict Header Workflow
- How Do I Decide If I Need a Common Network Ports List
- Code to Image Bulk: Turn Complete Code Into PNG