Skip to content

JSON Schema generator

Paste a JSON sample. A JSON Schema that describes it is written beside it.

The schema describes the sample, so it accepts the sample and little else. Add formats, enums, and limits before using it to validate real data.

Ctrl+Enter or ⌘+Enter runs this tool immediately.

Indent
JSON sample
JSON Schema

Waiting for input.

Parsing stays in this browser. Input is not uploaded or saved.

How to use this tool

  1. Paste a config file or API response, or load the sample.
  2. Read the schema. Each object lists its properties, and keys present in every sample object are listed under required.
  3. Copy the schema and tighten it, then test real files against it in the JSON Schema validator.

Supported formats and limitations

  • The schema uses draft 2020-12, the version the JSON Schema validator on this site checks.
  • Whole numbers become integer and other numbers become number. A field with both becomes number.
  • Objects in the same array are merged. A key missing from some of them is left out of required.
  • additionalProperties is not set, so extra keys are allowed. Add "additionalProperties": false to reject them.
  • Formats, patterns, enums, and minimum or maximum values cannot be inferred from one sample.

Examples

A key in some items

retries appears in one job, so it is a property of the job schema but not in its required list.

{"jobs": [{"name": "a"}, {"name": "b", "retries": 3}]}

A nullable value

An array of numbers and null gets items with "type": ["integer", "null"].

{"scores": [3, null]}

Common errors and solutions

Expected double-quoted property name
The sample is not strict JSON. Remove trailing commas and comments, or format it in the JSON formatter first.

FAQ

Can I use the schema in VS Code?
Yes. Save it as a file and point to it with the $schema key in your JSON, or with the json.schemas setting.
How do I check a file against the schema?
Paste the schema and the file into the JSON Schema validator. It lists each failing path.
Is the JSON uploaded?
No. The schema is generated in your browser.

Related tools

  • JSON Schema validator

    Check a JSON document against a JSON Schema in the browser. Draft-07 and 2020-12 are supported, and remote $ref values are not fetched.

  • JSON to TypeScript converter

    Generate TypeScript interfaces from a JSON sample in the browser. Array items are merged, and keys missing from some items become optional.

  • JSON to Zod schema converter

    Generate Zod schemas and inferred TypeScript types from a JSON sample in the browser. Optional keys use .optional() and null values use .nullable().