JSON Schema · Draft-07

Generate a JSON Schema from JSON

Turn a sample payload into a ready-to-use JSON Schema: inferred types, required fields, string formats, and array shapes — computed by a deterministic algorithm, not an AI guess.

1,000 free credits on signup · Draft-07 output

JSON Schema Generator
Generate in the editor
Input
Result

Generate a JSON Schema from this payload in the full editor.

Runs entirely in your browser — nothing is uploaded.

{"id":"usr_8801","email":"ada@example.com","active":true,"age":36,"roles":["admin","editor"],"profile":{"name":"Ada Lovelace","country":"UK","joined":"2021-04-12"},"credits":1000}
The JSON Schema Generator reads a sample payload and produces a JSON Schema (Draft-07) that describes it: property types, required keys, nested object and array shapes, and detected string formats such as email, date-time, and uuid. It is deterministic, not an AI guess — the same input always yields the same schema, computed by a rule-based algorithm on JSON Copilot’s own server — your JSON is never sent to a language model. It runs as a Copilot action inside the JSON Copilot editor, and you can apply the result to the Schema panel to validate future data in one click.

From sample JSON to a Draft-07 schema

Sample JSON
{
  "id": 42,
  "email": "ada@example.com",
  "active": true,
  "createdAt": "2026-01-14T09:30:00Z",
  "tags": ["admin", "beta"],
  "profile": { "name": "Ada", "age": 36 }
}
Generated schema (Draft-07)
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "email": { "type": "string", "format": "email" },
    "active": { "type": "boolean" },
    "createdAt": { "type": "string", "format": "date-time" },
    "tags": { "type": "array", "items": { "type": "string" } },
    "profile": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "age": { "type": "integer" }
      },
      "required": ["name", "age"]
    }
  },
  "required": ["id", "email", "active", "createdAt", "tags", "profile"]
}

The generator splits integer from number, detects the email and date-time formats, and marks every present key as required. It cannot know that tags is limited to a fixed set of roles or that age has a maximum — you add enum values and numeric bounds yourself before shipping the schema.

How to generate a JSON Schema

  1. 1

    Paste a representative sample

    Open the JSON Copilot editor and paste a JSON example that includes every field you want the schema to cover.

  2. 2

    Cover your variations

    Include several array items and any fields that are sometimes absent, so the generator can infer item shapes and which keys are genuinely required.

  3. 3

    Run the JSON Schema action

    In the Copilot panel, choose JSON Schema. The Draft-07 schema is computed by a deterministic algorithm — no language model is called.

  4. 4

    Review types and required keys

    Check the inferred types, the required array, detected formats, and any oneOf branches on mixed arrays before you rely on the output.

  5. 5

    Apply or copy the schema

    Apply it to the Schema panel to validate your data against it, or copy the raw Draft-07 JSON into your repository.

What the generator produces

Deterministic output

The same JSON always produces the same schema, so results are reproducible and diff-friendly in version control.

Full type inference

Detects objects, arrays, strings, integers versus numbers, booleans, and null across arbitrary nesting depth.

Required-key detection

Keys present in your sample land in the required array; null-valued keys are treated as optional.

String format heuristics

Recognises date-time, date, time, email, uuid, uri, and IPv4/IPv6 strings and adds the matching format keyword.

Mixed arrays via oneOf

Homogeneous arrays get a single items schema; arrays with differing shapes are described with oneOf branches.

Draft-07, ready to validate

Emits standards-compliant Draft-07 you can apply to the Schema panel or feed to any JSON Schema validator.

What is a JSON Schema?

A JSON Schema is a JSON document that describes the shape of other JSON documents. It declares what type each value should be, which properties are required, how arrays and nested objects are structured, and which string formats or value constraints apply. Draft-07 is one of the most widely supported dialects, understood by validators in virtually every language, which is why this generator targets it.

Schemas are built from a small vocabulary of keywords. type sets the JSON type (object, array, string, number, integer, boolean, or null); properties maps each object key to its own schema; required lists the keys that must be present; items describes array elements; format annotates strings like email or date-time; and enum, const, minimum, and pattern pin values down further. Because a schema is itself JSON, it lives in your repository and diffs cleanly.

Once you have a schema you can do more than validate. JSON Schema underpins OpenAPI request and response bodies, drives form generation, feeds code generators that emit types, and serves as living documentation of an API contract. Generating one from a real payload is usually the fastest way to bootstrap all of that.

How schema inference works — and where it stops

The generator walks your sample recursively. For each value it emits a type: numbers are split into integer or number, strings are pattern-matched against a small set of known formats (date-time, date, time, email, uuid, uri, and IPv4/IPv6), and objects become a properties map plus a required array. Arrays are handled by inferring a schema for every element and, when the elements agree, merging them into one items schema; when they differ, it falls back to oneOf branches, and an empty array yields an open items of {}.

That process is deterministic, so it never hallucinates a field and never varies run to run. But a single example is not the whole domain, and the algorithm only reports what the evidence shows. It marks every present, non-null key as required — almost always stricter than reality — and it cannot infer enums, numeric ranges, string length or pattern, or which fields are genuinely optional.

Format detection is a heuristic and can produce false positives: a dotted numeric code shaped like 203.0.113.5 is tagged as an ipv4 address, and any token with an @ and a dot can trip the email format even when it is not really an email. When two array elements are objects with overlapping keys, the merge marks a key required only if it appears in both, which is a useful signal that a field is optional. Knowing these rules tells you exactly what to double-check in the output.

Validating future data against the schema

Once you have a schema, apply it to the Schema panel to check documents against it. This is different from syntax validation: RFC 8259 validation only confirms that text is well-formed JSON, whereas schema validation confirms that a well-formed document also has the right types, required keys, and formats. A payload can be perfectly valid JSON and still violate your schema.

The same schema travels anywhere. Drop it into CI with a validator such as ajv (JavaScript) or python-jsonschema to catch contract drift before it ships, embed it in an OpenAPI definition so request and response bodies are enforced, or use it to power client-side form validation. The $schema keyword at the top declares the dialect so each validator selects the correct ruleset.

The main tuning knob is the required array. Keep it tight enough to catch genuinely missing fields, but loosen it for anything that is legitimately optional — otherwise every request that omits an optional key will fail validation. Because the generated required list is deliberately strict, this is usually the first thing to review.

Refining a generated schema

Treat the generated schema as a first draft that captures structure, then encode the rules only you know. The most common refinements are concrete: remove optional fields from required, add enum or const for values that come from a fixed set (a status field, a set of roles), and add minLength, pattern, minimum, maximum, or multipleOf wherever you have real bounds instead of leaving a bare string or number.

Tighten the edges the sample could not reveal. Replace the open items of {} that an empty array produced with a real element schema, delete any format that was a false positive, and add additionalProperties: false when you want to lock the object to exactly the keys you defined. Adding title and description keywords turns the schema into documentation as well as a validator.

For descriptions specifically, the Schema + Describe Copilot action generates the base schema with the same deterministic algorithm and then uses AI to add human-readable description fields, which is handy when the schema doubles as API docs. Keep the finished schema in version control, and when your payload changes, regenerate from a fresh sample and diff the two to see exactly what moved.

Frequently asked questions

How do I generate a JSON Schema from JSON?

Paste a representative sample into the JSON Copilot editor, open the Copilot panel, and run the JSON Schema action. It returns a Draft-07 schema with inferred types, required keys, formats, and array shapes that you can apply or copy.

Does the generator use AI?

No. The schema structure is produced by a deterministic, rule-based algorithm with no language-model call, so it never invents fields that were not in your sample. The separate Schema + Describe action does use AI to add human-readable description fields, but the schema structure itself is computed without one.

Is it free? Does it use credits?

New accounts get 1,000 free credits on signup, and JSON Schema runs as a Copilot action that draws from that balance based on how many properties it processes. Because there is no language-model call, it costs far less than the AI actions.

Is my JSON private?

Plain schema generation never sends your JSON to a language model — it is computed by a deterministic algorithm on JSON Copilot’s own server, and your data is never sold or shared. Detected sensitive values such as passwords, API keys, and emails are masked on your device before the request (on by default), so they reach the server only as placeholders. Saving results to your history is optional too: switch off "Save AI history" in Settings and your JSON and its results are not stored — only a content-free billing record of the credits used.

Can it handle large or deeply nested JSON?

Yes. It walks arbitrarily nested objects and arrays (with a depth guard around 50 levels) and merges repeated array items into a single item schema, so a large array of similar records produces a compact schema. The JSON Schema action runs in the editor and needs a connection, while formatting, validation, and tree view work fully offline in your browser.

What is the difference between generating a schema and validating JSON?

Syntax validation checks that text is well-formed JSON per RFC 8259. A JSON Schema describes the expected structure — types, required keys, formats — and Schema validation checks a document against that schema. This tool creates the schema; the Schema panel then validates data against it.

What can the generator not infer?

From a single sample it cannot know enums, numeric ranges, string patterns, or which keys are truly optional. It marks every present, non-null key as required and only detects formats it can pattern-match. Treat the output as a strong first draft and refine it by hand.

How do I refine the generated schema?

Loosen over-strict required arrays, add enum or const for fixed value sets, add minLength, pattern, or minimum/maximum where you have real bounds, and drop any false-positive formats. You can also run Schema + Describe to add description fields with AI.

Related tools

Generate your schema now

Open the Editor