JSC

JSON Schema Generator

Infer a reviewed starter schema from strict JSON samples

JSON & Data
πŸ”’ 100% client-side β€” your data never leaves this page
Maintained by Evanβ€’Updated: September 30, 2026

Infer a Draft 2020-12 or Draft 7 starter schema from one JSON value. A root array produces an array schema; object-array fields are combined under items, with missing fields distinct from null. Only observed types are inferred, not business ranges, formats or conditions. Empty-array items={} means the type is unknown.

Strict JSON: duplicate keys and numeric changes are rejected. Integers must be within Β±9007199254740991; decimals must round-trip to the same decimal value. Negative zero is unsupported. Input ≀2 MiB, depth ≀128, values ≀100000, output ≀8 MiB; paths ≀8192 characters, query results ≀10000, array indexes 0–99999.

Processing stays in this page. No JSON or path drafts, query scripts, or input keys, paths and values in analytics.

About this tool

Infer a Draft 2020-12 or Draft 7 starter schema from a strict JSON value. A root array remains an array schema; object samples are combined under items without confusing missing keys with null or inherited properties. Integers and non-integer numbers merge to number when both occur, nullable fields use type unions, and heterogeneous item types use anyOf. Choose keys present in every sample, all observed keys or no required fields; optionally add primitive examples and close objects with additionalProperties: false. Special keys are preserved, with an exact-name pattern for __proto__ validator compatibility. Empty arrays leave items unconstrained. Inference does not discover business formats, ranges, uniqueness or conditional rules. Numeric changes and duplicate keys are rejected before inference. Input is at most 2 MiB and output 8 MiB; no input drafts are saved.

Scenario Recipes

01

Separate a missing property from an explicitly null property

Goal: Build a starter contract without making optional evidence disappear.

  1. Paste [{"id":1,"note":null},{"id":2}]. Select Draft 2020-12 and Present in every object sample; leave examples and disallow extra fields off.
  2. Generate and inspect items.properties: id is integer and note is null. Only id appears in items.required.
  3. Validate both original records and an invalid record with id: "2". Add a string alternative to note only after confirming that the API permits it.

Result: The array schema preserves an optional null-only note field. Missing note does not imply a string type or require that property.

Failure Clinic (Common Pitfalls)

The generated contract rejects an original incomplete record

Cause: Every observed key makes all seen fields required, including keys absent from some records. Closing objects also rejects future fields that were never observed.

Fix: Use the default present-in-every-sample rule when source records should pass. Choose stricter required and closed-object rules deliberately, then test both complete and incomplete records.

A schema claims more certainty than the available samples

Cause: An empty array reveals no item type; a null-only field does not reveal its non-null type. One sample cannot establish allowed formats, ranges or unobserved alternatives.

Fix: Keep empty-array items unconstrained, add representative fixtures and review explicit business constraints separately. Store exact large IDs as strings before inference; rejected unsafe numbers should not be rounded merely to make the tool run.

Production Snippets

Expected schema for one missing note and one explicit null

json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" },
      "note": { "type": "null" }
    },
    "required": ["id"]
  }
}

Frequently Asked Questions

Which drafts and root values are supported?

Choose Draft 2020-12 or Draft 7. Objects, arrays and scalars are supported. An array of records generates type: array with inferred items; it does not silently become an individual record schema.

How are missing fields, null and required handled?

Missing keys supply no type evidence. Explicit null does. The default requires a key only when every object sample has it; all observed keys can intentionally make incomplete source records fail; none omits required.

How are mixed numbers and arrays inferred?

Integer and non-integer samples combine as number. A single non-null type plus null uses a type union, and several different types use anyOf. Object samples aggregate properties; an empty array uses items: {} because its item type is unknown.

Are __proto__ and constructor treated as real JSON keys?

Yes. Only own keys contribute data. __proto__ is retained under properties and repeated in an exact-name pattern because some validators, including Ajv 8, skip that name under properties. This also preserves its constraint when objects are closed.

Does the generated schema fully describe my API contract?

No. It cannot infer unobserved alternatives, formats, bounds, patterns, uniqueness or conditional rules. additionalProperties: false is an optional deliberate restriction. Check both passing and failing fixtures before adopting a contract.

What can the parser reject and is input saved?

Duplicate decoded keys, negative zero, unsafe integers, overflow, underflow and decimals that would change on serialization are rejected. Use strings for exact identifiers. Limits are 2 MiB input, 128 levels, 100000 values and 8 MiB output. Processing stays local; no JSON drafts or source values in analytics.

Keep browsing