Skip to main content

JSON to JSON Schema

Paste one or more JSON documents and get a JSON Schema (draft 2020-12 or 07) with required fields and formats detected. Private.

Paste JSON on the left. Add a second sample to find optional fields.

JSON input

Stays in your browser

JSON Schema code

The generated code appears here.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Next steps

Free Online JSON to JSON Schema Generator

Generate a JSON Schema from sample data, then use it to validate other documents. It gives developers a quick browser-based way to solve a focused json to json schema task before moving the result into a project.

How to generate JSON Schema code from JSON

Paste a JSON object or an array of objects into the input box and press Generate. Required fields come from all samples: a key present in every sample is required. Formats such as date-time, email and uri are detected, and additionalProperties: false is one switch away.

One input, every language

Your JSON stays in the box when you switch the language tabs, and the code is generated again at once. Each language also has its own page, so you can bookmark the one you use.

How types are worked out

  • Whole numbers and numbers with decimals are told apart.
  • Add more samples with Add sample: a key missing from some samples becomes optional, and null makes a type nullable.
  • Arrays of objects are merged into one type, and nested objects become their own types named after the key.
  • Keys that are not valid names in the language (such as first-name or 2fa) are renamed and mapped back, never rejected.

Worked example

The sample JSON in the box above, generated with the default options:

{
  "id": 1,
  "name": "Ada",
  "email": null,
  "tags": ["x"],
  "address": { "city": "Pune", "pin": "411001" },
  "createdAt": "2026-01-15T10:30:00Z"
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Root",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "email": {
      "type": [
        "string",
        "null"
      ]
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "address": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string"
        },
        "pin": {
          "type": "string"
        }
      },
      "required": [
        "city",
        "pin"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "name",
    "email",
    "tags",
    "address",
    "createdAt"
  ]
}

Common mistakes

  • A single sample cannot show which fields are optional. Paste two or three different responses for a realistic result.
  • A value that is always null gives no type information, so it is treated as a nullable string. Change it by hand if it is something else.
  • Numbers are typed from the samples: 1 and 1.0 look the same in JSON, so use a sample with decimals where you need a float.

Frequently asked questions

How is required decided?
A key that appears in every sample is required. Add several samples to get a realistic required list.
Which draft should I use?
2020-12 is the current one. Choose draft-07 for tools that have not moved on, such as many older validators.
Can I validate with the result?
Yes. Paste the schema into the JSON Schema Validator on this site along with a document to check.
Is my JSON uploaded?
No. The types are worked out in your browser. Nothing you paste is sent to a server.
How do I use this json to json schema tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More Formatters & Parsers

View all Formatters & Parsers tools →