JSON Schema Generator (JSON to JSON Schema)

Developer Tools

Paste one or more JSON samples and get a JSON Schema that describes them, with types, required fields and detected formats.

Options
JSON sample
JSON Schema

Processed in your browser. A copy of each run is saved to your past runs so you can reopen it. Privacy

About

What the JSON Schema Generator does

The JSON Schema Generator turns example JSON into a schema: it reads every value, records its type, follows nested objects and arrays, and marks which properties are required. Several samples (one per line) are merged, so optional fields and mixed types show up correctly. It writes draft 2020-12 or draft-07 and detects emails, dates and URLs. It is for developers writing API contracts and config validation. A schema inferred from samples is a first draft to review, not a specification.

Steps

How to use it

  1. 1Paste a JSON object or array into the left panel. For several samples, put one JSON object per line.
  2. 2Choose the draft, how required properties are decided, and whether extra properties are allowed.
  3. 3Press Generate schema (or Cmd/Ctrl+Enter).
  4. 4Review the schema, then copy it or download it as schema.json.

Example

A real run

Input

{"name": "Ada Lovelace", "email": "ada@example.com", "signedUpAt": "2026-11-27T14:05:00Z", "seats": 3, "tags": ["beta", "us-east"]}

Output

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "signedUpAt": {
      "type": "string",
      "format": "date-time"
    },
    "seats": {
      "type": "integer"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "name",
    "email",
    "signedUpAt",
    "seats",
    "tags"
  ],
  "additionalProperties": true
}

One sample, default settings: every property is required because the single sample has them all. The email and the timestamp were detected as format email and date-time, seats as an integer, and tags as an array of strings.

Options

Every setting, and when to use it

Draft: 2020-12 or draft-07
2020-12 is the current JSON Schema release and the one OpenAPI 3.1 uses. Draft-07 is older but still the default in many validators and tools. The structure is the same for what this tool generates; only the $schema URL differs, and the uuid format is written only for 2020-12, where it is defined.
Required: properties in every sample, every property seen, or none
In every sample marks a property required only if all samples have it, which is the right choice when you paste several records. Every property seen treats a single sample as complete. None leaves required out, for a permissive schema you tighten by hand.
Allow extra properties
On writes additionalProperties: true, so data with unknown keys still passes. Off writes false, which rejects any key the samples did not have; use it for strict API contracts and config files.
Detect string formats
When every value of a field matches, the schema adds format: email, date-time, date, uri or uuid. Validators treat format as an annotation unless configured to assert it, so it documents intent even where it is not enforced.
Add examples
Adds an examples array with the first sample value to each field, which documentation tools and editors show as a hint. Leave it off if the samples contain real customer data.

Good to know

Common problems and limits

The schema describes the samples, nothing more. Enumerations, minimum and maximum values, string lengths and patterns are not inferred; add them by hand where the data needs them. If no sample contains a field, the schema cannot know it exists.

A field that is a number in one sample and a string in another becomes an anyOf of both types; a field that is sometimes null becomes a two-type list such as ["string", "null"]. Both are correct but usually worth a second look, since they often point at inconsistent data.

An empty array gives items: {}, which accepts anything, because there is nothing to infer from. Integers and decimals in the same field are merged into number.

Input is limited to 5 MB. Invalid JSON is rejected with the parser's message; the JSON Validator shows the exact line, column and a fix.

Audience

Who uses it

  • API developersDraft the request and response schemas for an OpenAPI 3.1 document from real payloads, then tighten them by hand.
  • Platform and DevOps engineersWrite a schema for a JSON config file so editors like VS Code can autocomplete and flag mistakes.
  • Data engineersDescribe the records of a JSON Lines export before loading it, and spot fields that change type between rows; flatten the same records with the JSON to CSV converter.
  • QA engineersGenerate a schema from a known-good response and use it in contract tests to catch breaking API changes, alongside JSON Compare for one-off diffs.

FAQ

Frequently asked

What is JSON Schema?

JSON Schema is a standard vocabulary for describing the shape of JSON data: which properties an object has, their types, which are required and what formats strings follow. Validators use a schema to check data, editors use it for autocomplete, and API specifications such as OpenAPI use it to define requests and responses.

What is the difference between draft-07 and 2020-12?

2020-12 is the current JSON Schema release; draft-07 dates from 2018 and is still the default in many tools. For schemas like the ones generated here the only visible differences are the $schema URL and the uuid format, which draft-07 does not define. Choose 2020-12 for OpenAPI 3.1, draft-07 if your validator is older.

How does the generator decide which fields are required?

With the default setting, a property is required only if it appears in every sample you provide, so fields missing from some records stay optional. With one sample, every property it contains is required. You can switch to treating every property seen as required, or to leaving required out entirely.

How do I validate JSON against the generated schema?

Use a JSON Schema validator library: Ajv for JavaScript and TypeScript, jsonschema for Python, or the validator built into your API framework. This site's JSON Validator checks JSON syntax only, which is the step before schema validation, not a replacement for it.

Why does a field have two types, like string and null?

Because the samples disagree: the field held a string in some records and null in others, so the schema allows both. If null should never appear, the data has a problem worth fixing; if it is expected, the schema is right as generated.

Can I generate TypeScript types from a JSON Schema?

Yes, with a separate tool. Packages such as json-schema-to-typescript turn a schema into TypeScript interfaces, and many API code generators read JSON Schema through OpenAPI. Generate the schema here, review it, then feed it to the generator your project uses.

Automation: an MCP tool generate_json_schema(json, draft, required) → schema and an n8n node are planned for this tool.

Built and maintained by Radhika SinghLast updated Questions: hello@operativez.ai