Developer Tools

JSON Schema Generator

Build a reviewable schema from an example response or fixture. The generator combines array samples, distinguishes missing fields from null values, and writes a real Draft 2020-12 schema document.

Free online tool

Loading tool…

149 / 500,000 characters. Processing stays in this browser.

Infer a Draft 2020-12 schema

Array items are merged as samples. A property is required only when it appears in every sampled object at that location. Null stays a separate allowed type, and different types use anyOf. Empty arrays leave items unconstrained.

This schema describes observed shapes. It does not infer a complete API contract, string formats, enums, ranges, or every possible optional field. Review required and additionalProperties before using it to validate production data.

All parsing and exports run locally in your browser. Example records are original fictional data, not an external dataset.

GET STARTED

How to use the JSON Schema Generator

  1. 01

    Paste one valid JSON value. Put multiple record examples in an array.

  2. 02

    Optionally give the schema a title and decide whether extra object properties should be rejected.

  3. 03

    Generate the schema, review its required fields and unions, and download schema.json.

Examples

Optional and nullable fields

For [{"id":1,"email":null},{"id":2}], id is required; email is optional and has type null. Add a string example to allow string emails.

Mixed array values

[1, 2.5, "unknown"] produces array items that allow numbers or strings. An empty array produces an unconstrained items schema.

Required means observed in every sample

Object examples at the same array-item location are merged. A key becomes required only if it exists in every observed object there. Null is a present value, not an absent key. Nested objects follow the same rule independently. A single object therefore makes all of its observed keys required.

Avoid guessing constraints from coincidences

A value that looks like an email does not establish an email contract. The generator deliberately omits inferred formats, enums, minimums, maximums, and length limits. It also leaves additional properties allowed unless you enable the explicit closed-object option. That option applies recursively and may be too strict for evolving APIs.

Exact numeric classification

JSON numeric tokens are examined without converting them to floating-point numbers. Whole mathematical values, including 1.0 and 2e3, infer integer; fractional values infer number. When both occur at one location, number includes both. Duplicate object keys are rejected rather than silently overwritten.

What to know

  • Input is limited to 500,000 characters. Review the supported syntax and export policy described above.

Common questions

Does this prove my API contract?

No. It describes the shapes in your examples. Review it against real requirements and validate more representative data before adopting it.

Which JSON Schema dialect is emitted?

Draft 2020-12. The output declares https://json-schema.org/draft/2020-12/schema in $schema.

Why is an empty object permissive?

There are no observed property constraints. Enable rejection of additional properties only when an empty object must truly remain empty.

Sources & references