Skip to content

JSON to JSON Schema Generator

Paste an example JSON document and get a JSON Schema describing it, ready to copy. Your JSON is analysed in your browser and never sent anywhere.

Options

JSON Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "email": {
      "type": "null"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "address": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        }
      },
      "required": [
        "city",
        "zip"
      ]
    },
    "orders": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "total": {
            "type": "number"
          },
          "coupon": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "total"
        ]
      }
    }
  },
  "required": [
    "id",
    "name",
    "email",
    "tags",
    "address",
    "orders"
  ]
}

Your JSON is analysed in your browser. It is never uploaded, saved or logged.

How it works

  1. Paste a sample JSON document into the box. The example shows the format.
  2. Choose Draft-07 or 2020-12.
  3. Tick “Mark properties as required” and “Allow null” to match your data rules.
  4. Copy the schema. If the JSON is invalid, the error tells you the line and column.

What people use it for

  • Document an API

    Turn a real response into a starting schema for your OpenAPI file or docs.

  • Validate config and payloads

    Generate a schema from a known-good file, then tighten it by hand and validate with your favourite library.

  • Bootstrap types

    Use the schema as the first step to generate code types or form definitions.

Questions

How are types worked out?
Each value gives its JSON type: string, boolean, null, integer (a number with no decimals), number, object or array. If an integer and a decimal both appear in the same place, the type becomes number.
How are arrays and mixed values handled?
All elements of an array are merged into one items schema. Objects in the array are merged property by property; with “required” on, only properties present in every object are required. Different primitive types become a type list such as ["string", "integer"].
What do “required” and “Allow null” do?
“Mark properties as required” lists every property seen in all sample objects under required. “Allow null” adds null to the type of each object property, so a null is accepted there. Neither changes array items or the root.
Is the schema final?
No: a sample cannot tell the intended rules, so treat the result as a draft. It does not guess formats, lengths, enums or ranges. The only difference between the two drafts here is the $schema line.