JSON Schema Generator
Paste JSON samples and get a JSON Schema that accepts them, ready to refine.
Try before you buy.
- Free preview: the first lines of the generated schema (up to 20), with its sample, property, format and enum counts and every note.
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment unless you choose automatic renewal. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment unless you choose automatic renewal.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
The schema updates as you type. You can drop a .json or .jsonl file here — it is read on your device, never uploaded.
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the JSON Schema Generator
Paste a JSON document — an API response, a config file, a record from a log — and get a JSON Schema that describes it: the type of every field, which keys are required, which fields can be null, and formats such as date-time, email, uri and uuid where every value has them. Paste several samples (JSON Lines, or documents one after another) and the generator learns from all of them: a key that appears in only some samples becomes optional, and a field that is sometimes null becomes nullable.
Choose draft 2020-12 or draft-07, and decide whether to forbid extra keys, turn small sets of repeated values into enums, and add examples and titles. Every schema the generator writes accepts the samples it came from — that is tested with the same engine as the JSON Schema Validator, formats included. This is JSON Schema for validating data; for schema.org markup in web pages, use the Schema Markup Generator.
Without a pass you see a free preview: the sample, property, format and enum counts and every note, with the first lines of the schema. A Pro pass unlocks the whole schema, with Copy, Download and the hand-over to the validator.
How to use it
- Paste a JSON sample, open or drop a file, or press Load sample. For several samples (JSON Lines, or values one after another), choose Several samples.
- Pick the draft: 2020-12 (the current version, also the one OpenAPI 3.1 uses) or draft-07 (for validators that do not support 2020-12 yet).
- Set the options: required keys, extra keys allowed or forbidden, formats, enums for small sets of repeated values (and their size limit), examples and titles, and an optional title and description for the schema.
- Copy or download the schema, or press Validate in the JSON Schema Validator to open that tool with your first sample as the document and the schema copied, ready to paste into its JSON Schema box — with a pass, or after unlocking this result.
Examples
{"id": 7, "email": "asha@example.com", "score": 4.5, "tags": ["a"], "manager": null}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": { "type": "integer" },
"email": { "type": "string", "format": "email" },
"score": { "type": "number" },
"tags": { "type": "array", "items": { "type": "string" } },
"manager": { "type": "null" }
},
"required": ["id", "email", "score", "tags", "manager"]
}Shown compactly. With a single sample every key is required and manager can only be null — add samples to teach the generator more.
{"a": 1, "b": "x"}
{"a": 2, "b": null, "c": true}
{"a": 3}"properties": {
"a": { "type": "integer" },
"b": { "type": ["string", "null"] },
"c": { "type": "boolean" }
},
"required": ["a"][{"status": "paid"}, {"status": "refunded"}, {"status": "paid"}]"status": { "type": "string", "enum": ["paid", "refunded"] }With Enums ticked: a field becomes an enum when its values repeat and there are no more than the limit (5 by default).
Common uses
- Writing a first schema for an API, a webhook payload or a message queue from real examples, then tightening it by hand.
- Documenting the shape of JSON Lines logs or exported records, including which fields are optional.
- Starting the request and response schemas of an OpenAPI description from captured traffic.
- Producing a schema to check configuration files in CI or in an editor that understands JSON Schema.
How the schema is inferred
- Types:
integerwhen every number is written without a fraction or an exponent, otherwisenumber;string,boolean,array,objectandnullas seen. A field with several kinds of value gets a list ("type": ["number", "string"]), oranyOfwhen the kinds need their own keywords (an object and a string). - required: the keys present in every object at that place. With one sample that is all of them.
- Nullable: a field that is sometimes
nullgets"null"added to its type. - Arrays: all items are merged into one
itemsschema, so[1, "a"]gives items of type number or string. - Formats:
date-time,date,time,email,uri,uuid,ipv4,ipv6andduration, only when every string at that place has the format. Times need an offset (10:30:00Z), as RFC 3339 requires, so a local time such as10:30:00stays a plain string;urineeds a scheme such ashttps://, so text likeenv:prodis not taken for one. - enum (optional): strings or integers whose values repeat, with no more different values than the limit.
Draft 2020-12 or draft-07?
For the schemas this tool writes, the two drafts differ only in $schema: the keywords used (type, properties, required, items, enum, format, additionalProperties, examples, anyOf, title, description) mean the same in both. Choose 2020-12 unless the validator or tool that will read the schema only supports draft-07. In both drafts format may be treated as an annotation unless the validator is set to check it.
Limitations
- A schema inferred from examples only knows what the examples show: check that required keys really are required, and add limits such as minimum, maxLength or pattern yourself.
- Objects used as dictionaries (keys that are IDs, such as {"user123": …}) are described key by key; rewrite them with additionalProperties or patternProperties if the keys vary.
- Arrays are described by one merged items schema; tuples (a fixed type at each position) are not detected.
Privacy
On this device: nothing is sent
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What do I get without a pass?
Without a pass, JSON Schema Generator shows the first lines of the generated schema (up to 20), with its sample, property, format and enum counts and every note. Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment unless you choose automatic renewal, unlocks the full result. The pricing page lists the passes and their prices.
Is my JSON uploaded?
No. The schema is generated in your browser, and the page works offline once loaded.
Why is every key required?
With one sample, the generator cannot tell which keys are optional, so it marks all of them as required. Choose Several samples and paste more examples, or untick Required keys to leave required out.
Why did a field get no format?
A format is added only when every value at that place has it. One value that is not a date, or a time without an offset such as 10:30:00, keeps the field a plain string. Untick Formats to never add them.
Can I use the schema with OpenAPI?
OpenAPI 3.1 schemas are a superset of JSON Schema 2020-12, so a 2020-12 schema from here works there. OpenAPI 3.0 is based on an older draft and has no "null" type: write "type": "string" with "nullable": true instead of "type": ["string", "null"], and use example instead of examples.
Do I need a pass?
To copy, download or hand over the whole schema, yes: a Pro pass unlocks every Pro tool. Without a pass you see a free preview of your own result: the first lines of the generated schema (up to 20), with its sample, property, format and enum counts and every note. Your samples are never locked and never uploaded.
Learn more
Lessons on MySmartCoPilot Learn that use this tool:
- Your first JSON Schema 2020-12 Free lesson, Pro answers
- Objects and arrays in JSON Schema Free lesson, Pro answers
- Validate every record: schemas and quarantine Free core, Pro depth