Schema inference

JSON Schema generatorreview the contract behind your samples

Start with the example. Select multiple samples only when each top-level array element represents a separate document.

JSON Schema generator

JSON samples

Schema output

Processing stays in this browser; samples are not uploaded or stored.

Inference options

A sample is not a business contract. All required may reject sparse samples; enum can overconstrain values.

1 samples · 7 properties · 0 enums · 0 enums omitted

A JSON Schema generator is useful when the available documentation is a handful of API responses. Combine representative records to reveal optional keys and mixed value types, then inspect the proposed contract instead of treating one response as universal.

Missing and null describe different situations. A required key can still contain null; a non-nullable property may still be absent. The independent controls keep those decisions visible while you develop a schema from evidence.

Why use this JSON Schema generator?

Look beyond the first record

The JSON Schema generator examines every array element at the same structural position. A field missing from a second object drops out of common required, while an explicit null expands its type. Unrelated nested objects are not merged merely because their keys match.

Two record cards feed a shared tree; a missing field becomes a dashed branch and a null value remains a hollow marker.

Keep manual constraints under your control

Enter edit mode to add descriptions or domain rules. Automatic generation stops. If you change the samples and generate again, a separate candidate appears; applying it replaces one schema, with an undo that restores the prior input, options and output.

A generated tree passes through a pencil review step; a separate candidate sits beside the preserved earlier draft.

Make the sample boundaries explicit

01

Decide what the outer array means

Single-document mode preserves an outer array as the root type. Multiple-sample mode instead merges its elements into one schema for an individual document. To compare array documents, supply an array of arrays.

02

Choose presence and null separately

Common required uses only object samples at the same position. All required deliberately demands the union of observed fields, even when an earlier sample lacks one. Allowing null does not make a required key optional.

03

Refresh without losing manual edits

Input and option changes immediately disable export. Automatic generation waits 350 ms; manual mode supports Ctrl/Cmd+Enter. Editing stops automatic generation. A new candidate requires Apply, and Undo restores the previous state.

Decisions the inference engine makes

One compatible subset, three dialects

Select Draft 7, 2019-09 or 2020-12 for the target validator. The JSON Schema generator uses shared type, properties, required, enum and single-schema items syntax. Only the $schema URI differs; this is not a migration tool for existing schemas.

Array evidence is merged completely

Empty arrays contribute no element type. With only empty arrays, items is an unconstrained object. Mixed numbers become number when any value has a fractional part; 1.0 and 100e-2 remain integer by their mathematical value.

Opt-in scalar enumerations

Enable enum inference only when observed values should be the allowed set. Each scalar position collects at most 20 distinct values, counting an added null. Above that limit the entire enum is omitted and the status counts the omission. Objects and arrays are never enum candidates.

An editable JSON to JSON Schema result

Schema inference preserves numeric tokens, including integers beyond JavaScript’s safe range. Equivalent numeric values are deduplicated without rounding. Multiple JSON samples can expose variants, but manual edits receive syntax and root-shape checks only, not full schema validation.

What samples cannot establish

No guessed business constraints
Dates remain strings: format, pattern, ranges, lengths and default values are not inferred. Additional properties remain allowed. Review both rules and representative failing examples before applying the contract to production data.
Samples do not reveal every alternative
Null-only evidence produces null; it cannot reveal a hidden non-null type. Empty arrays produce unconstrained items. Field correlations and discriminator branches are not preserved, so the merged contract can allow combinations absent from the samples.
No tuples or first-element shortcut
All array elements feed one items schema. The generator does not infer tuple positions, fixed lengths, references or conditional constraints. Required=all may intentionally reject an original record that lacks a union field.
Edited output is not semantically certified
Edit mode accepts a JSON object or boolean schema and rejects syntax errors or duplicate keys. It does not check every keyword against a metaschema, resolve references or validate business samples. Invalid keyword meanings can still be exported after a syntax check.
Bounded, strict documents
Input and output each allow 500,000 characters and 50,000 parsed nodes; input nesting is capped at 40 and edited output at 100. Multiple mode accepts 1–1,000 samples. Comments, trailing commas, NDJSON, files and URL fetching are unsupported. A generated-output budget failure stops the whole result.

JSON Schema generator questions

Why generate a JSON Schema from multiple samples instead of one?

Several records can expose disappearing fields, nulls or changed types that one successful response hides. Choose Multiple samples and place independent documents in one outer array; that wrapper does not become the generated root type.

How does merging decide which fields are required?

With Common required, a field is required only when it appears in every object at that position. Null still counts as present. Choose All required or No required fields to impose a different presence policy deliberately.

How are fields with different types across samples handled?

The allowed types are combined. Integer and fractional observations become number; null is included when seen. Object properties and array items are merged within their own branches, without preserving correlations between other fields.

How many JSON samples can I merge?

Multiple mode accepts up to 1,000 documents in one nonempty array, subject to the character, depth and node budgets. Fewer representative examples are often more useful than thousands of identical successful responses.

Does it still infer formats like email, date-time, and UUID?

No. Email addresses, dates and UUIDs remain strings. Add a format yourself only when it is a genuine contract requirement, then check how your chosen validator handles that annotation.

Found an inference case worth checking?

Review before adopting the contract

Use the JSON Schema generator with ordinary and edge-case records, then edit the inferred constraints before adding validation to your project.