JSON Schema Generator — Infer a Schema from JSON
This free online JSON Schema generator turns a sample JSON payload into a valid JSON Schema. Paste a representative example — an API response, a config file, a database record — and the tool infers the structure: the type of every value, the properties of each object, the shape of array items, and which keys are required. It is a fast way to bootstrap the schema you would otherwise write by hand before validating data, generating types, or documenting an API.
Everything runs locally in your browser. The JSON you paste is parsed and analyzed on your device and is never uploaded, so it is safe to use with private or unpublished data. The generated schema is a starting point: inference is only as complete as your sample, so review the result and tighten it (add descriptions, constraints, or enums) before relying on it.
How to use JSON Schema Generator
- Paste your JSON into the input box, or press Load sample to see an example.
- Choose the schema dialect: Draft-07 (default) or Draft 2020-12.
- Toggle options such as marking properties required, integer vs number, string format detection, additionalProperties: false, and including examples or titles.
- Read the generated schema in the output panel; it updates as you type.
- Copy the schema to your clipboard or download it as schema.json.
How the inference works
Each value is mapped to a JSON Schema type: string, number, integer, boolean, null, object, or array. Numbers that have no fractional part are reported as integer unless you turn that option off, in which case every number is number.
For objects, the tool lists every key under properties and, by default, marks all present keys as required. When the same object shape appears several times inside an array, the property sets are merged and a key is only kept in required if it is present in every one of those objects — so optional fields are detected automatically.
For arrays, the schemas of all elements are merged into a single items schema. Compatible values combine (for example a mix of integers and decimals widens to number), while genuinely different shapes are combined with anyOf. An empty array produces a plain array type with no item constraints, so it accepts anything.
[{ "id": 1, "name": "a" }, { "id": 2, "name": "b", "nickname": "bee" }]
// items.required -> ["id", "name"] (nickname is optional)String format detection
When Detect string formats is enabled, string values are matched against common patterns and annotated with a format keyword. Detection is heuristic — it recognizes the shape of the value, it does not guarantee the value is semantically valid.
- date-time — an RFC 3339 timestamp such as 2024-01-15T09:30:00Z.
- date — a calendar date such as 2024-01-15.
- email — an address such as ada@example.com.
- uri — a value with a scheme such as https://example.com.
- uuid — a canonical UUID such as 550e8400-e29b-41d4-a716-446655440000.
- ipv4 — a dotted-quad address such as 192.168.0.1.
Draft-07 and Draft 2020-12
The dialect selector sets the $schema URI at the top of the document: http://json-schema.org/draft-07/schema# for Draft-07 and https://json-schema.org/draft/2020-12/schema for Draft 2020-12. Because array elements are merged into one items schema, the generator never emits the tuple-validation keywords that differ between the two drafts, so the body of the schema is valid under either dialect.
Options
- Mark properties required — list every present key in required (on by default); turn off to leave all properties optional.
- Integer vs number — report whole numbers as integer (on) or treat all numbers as number (off).
- Detect string formats — add format annotations to recognized strings.
- additionalProperties: false — make objects strict so no extra keys are allowed.
- Include examples — attach an examples array to scalar values, drawn from your sample.
- Include titles — add a title to the root and to each property (the property key), a useful starting point for documentation.
Related terminology
- JSON Schema
- A vocabulary for describing and constraining the structure of JSON data, used for validation, documentation, and code generation.
- Dialect / draft
- A specific version of the JSON Schema specification, such as Draft-07 or Draft 2020-12, declared with the $schema keyword.
- required
- A keyword listing the property names that must be present on an object. This tool infers it from the keys found in your sample.
- format
- An annotation on a string, such as email or date-time, that describes the expected content. It is advisory unless a validator is configured to enforce it.
- anyOf
- A keyword meaning a value may match any one of several subschemas. Used here when the elements of an array have incompatible types.
Frequently asked questions
- How do I generate a JSON Schema from JSON?
- Paste a representative JSON sample into the input box. The tool parses it and produces a matching JSON Schema instantly, which you can copy or download as schema.json.
- Which JSON Schema drafts are supported?
- Draft-07 (the default) and Draft 2020-12. The selector sets the $schema URI; the rest of the generated schema is valid under either dialect because the tool avoids the keywords that differ between them.
- How are required properties decided?
- By default every key present in an object is marked required. When an object shape repeats inside an array, a key stays required only if it appears in all of those objects, so optional fields are detected. You can disable required entirely with a toggle.
- How does it handle arrays with mixed types?
- It merges the schemas of all array elements into one items schema. Compatible values combine (integers and decimals widen to number), and genuinely different shapes are represented with anyOf. An empty array yields an array with no item constraints.
- Does this validate my JSON against a schema?
- No. It infers a schema from an example; it does not validate data against an existing schema. Treat the output as a well-formed starting point and refine it — adding descriptions, enums, or numeric bounds — for production use.
- Is my data uploaded anywhere?
- No. Parsing and schema generation happen entirely in your browser, so your JSON never leaves your device.