JSON Schema Generator

Skip to editor
Explorer
Open Files

No files open

0 files open

jsoneditor.io v2

{
  "orderId": "ord_8F2K1",
  "status": "shipped",
  "customer": {
    "id": 4182,
    "name": "Ada Lovelace",
    "email": "ada@example.com"
  },
  "items": [
    {
      "sku": "KB-104",
      "name": "Mechanical keyboard",
      "qty": 1,
      "price": 89.99
    },
    {
      "sku": "MS-220",
      "name": "Wireless mouse",
      "qty": 2,
      "price": 24.5
    }
  ],
  "total": 138.99,
  "paid": true,
  "notes": null
}
JSONUTF-8
Spaces: 2

How do I generate a JSON Schema from JSON?

To generate a JSON Schema, paste a sample above, open Convert and press JSON Schema. A draft 2020-12 schema opens in a new tab, describing every object, array and value in your sample.

Keys present in every item are listed as required, whole numbers are typed as integer, values that are sometimes null get a type like ["string", "null"] and arrays of objects are merged into one item schema. Treat it as a strong first draft and add formats, patterns and limits by hand.

  1. Paste a sample JSON document into the editor.
  2. Open Convert and press JSON Schema.
  3. Refine the schema in the new tab.

Example

JSON
{
  "orderId": "ord_8F2K1",
  "status": "shipped",
  "customer": {
    "id": 4182,
    "name": "Ada Lovelace",
    "email": "ada@example.com"
  },
  "items": [
    {
      "sku": "KB-104",
      "name": "Mechanical keyboard",
      "qty": 1,
      "price": 89.99
    },
    {
      "sku": "MS-220",
      "name": "Wireless mouse",
      "qty": 2,
      "price": 24.5
    }
  ],
  "total": 138.99,
  "paid": true,
  "notes": null
}
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "orderId": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "customer": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name",
        "email"
      ]
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sku": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "qty": {
            "type": "integer"
          },
          "price": {
            "type": "number"
          }
        },
        "required": [
          "sku",
          "name",
          "qty",
          "price"
        ]
      }
    },
    "total": {
      "type": "number"
    },
    "paid": {
      "type": "boolean"
    },
    "notes": {
      "type": "null"
    }
  },
  "required": [
    "orderId",
    "status",
    "customer",
    "items",
    "total",
    "paid",
    "notes"
  ]
}

Questions people ask

Which JSON Schema version does it generate?

Draft 2020-12, the current version, which Ajv, OpenAPI 3.1 and most modern validators support.

Why is a key required in the schema?

It appeared in every object at that position in your sample. If it can be missing in real data, remove it from required or add a sample without it.

Is my data uploaded anywhere?

No, this runs entirely in your browser, so nothing you paste is sent to a server. The only feature that sends data anywhere is the optional AI assistant, and only when you actually ask it something.