JSON Schema Generator
Infer schemas from sample JSON.
About JSON Schema Generator
JSON Schema Generator infers a schema from a sample JSON document. Paste one representative object or array and it derives every type: strings, numbers, integers, booleans, nested objects, and arrays, including merged item types when an array mixes shapes. Optional detection adds string formats such as email, date-time, and uuid, and enum lists when a field repeats a small set of values. The output targets Draft 2020-12 or draft-07, the dialects behind structured outputs and function calling in major AI APIs, so you can paste the schema straight into those features.
How to Use JSON Schema Generator
Paste a representative sample
Paste one JSON document that shows every field, or a small array so array items can be merged. Click Sample to see the shape the tool expects.
Set the options
Choose Require observed keys or No required list, and toggle Forbid extra properties, Detect enums, and Detect string formats.
Generate and use
Click Generate schema. The result appears on the right with a $schema line for Draft 2020-12 or Draft-07. Copy it or Download it as schema.json.
Why Use JSON Schema Generator: Common Use Cases
Structured outputs in AI APIs
OpenAI, Anthropic, and Google all accept a JSON Schema to force validatable output. Generate it from one hand-written perfect example instead of writing schema by hand.
Function calling parameters
Tool definitions in AI SDKs take a parameters object that is a JSON Schema. Paste the arguments of one ideal call and get that object ready.
Validating API payloads
Capture one real response, generate the schema, and use it in tests or runtime validation to catch regressions in an API you consume.
Documenting data files
A schema is executable documentation: reviewers see which fields are required and what types they hold.
JSON Schema Generator Specifications
| Input Formats | JSON |
|---|---|
| Output Formats | JSON Schema |
| File Size Limit | No strict limit (dependent on device memory) |
| Processing Engine | 100% Client-side (Runs locally in your browser) |
| Data Retention | Files never leave your device |
| Batch Processing | Single file processing |
Tips for JSON Schema Generator
Include null where a field is nullable; the generator records it as a null type and merges it into the field's type list.
For enum detection to fire, every observed value must be one of a small set of short strings. One outlier string turns the field back into plain string.
Arrays of objects are merged: a key required in the schema appeared in every element of your sample.
Check the finished document with JSON Formatter before shipping it into a validator.
Clean the sample first with Code to Prompt Converter habits in mind: comments and trailing commas are not valid JSON.
Frequently Asked Questions
What is the difference between Draft 2020-12 and draft-07?
They are two versions of the JSON Schema specification. New validators and AI APIs generally expect 2020-12; older libraries and some ecosystems still require draft-07. The generator writes the matching $schema line for whichever you pick.
How are array item types decided?
Every element is inferred separately and the results are merged. Identical scalars collapse to one type, mixed scalars become a type list, and objects merge their properties, keeping as required only the keys present in every element.
Which string formats are detected?
Email, date-time, date, time, uuid, and uri, checked with conservative patterns. Detection only fires when every observed value for that field matches, and you can switch it off entirely.
What does Forbid extra properties do?
It sets additionalProperties to false, so validation fails when a document contains keys your sample did not show. Leave it off for APIs that add fields over time.
Can one sample really define a schema?
It defines a lower bound: types and required keys you have seen. Fields that appear sometimes should be sampled in both states, and optional keys are best modeled by pasting a sample that omits them and choosing no required list.
Is my data uploaded anywhere?
No. Parsing and inference run in your browser with native JSON.parse, so sample payloads with personal or internal data stay on your device.