Skip to content
BEAD

JSON Sample → JSON Schema

Infer a Draft 2020-12 JSON Schema from a sample value or array of objects, with auto-detected formats.

JSON Schema (Draft 2020-12)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "active": {
      "type": "boolean"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "profile": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "age": {
          "type": "integer"
        }
      },
      "required": [
        "age",
        "name"
      ],
      "additionalProperties": false
    },
    "lastLogin": {
      "type": "null"
    }
  },
  "required": [
    "active",
    "email",
    "id",
    "lastLogin",
    "profile",
    "tags"
  ],
  "additionalProperties": false
}

How it infers

Each field gets the narrowest JSON Schema type that fits every observed sample. Arrays of objects merge into a singleitems shape — keys present in some samples but not others are dropped from required. Integers stayinteger until they meet a float, then promote tonumber.

Multiple samples

Pass an array of objects at the top level to widen the schema — very useful for shaping API responses from a handful of fixture payloads.

You might also like

Used in these workflows