JSON to JSON Schema

Generate a draft 2020-12 JSON Schema from any JSON sample. All keys are marked required by default.

Runs in your browser Instant No signup, no tracking

About this tool

Paste a sample JSON document and get a draft 2020-12 JSON Schema you can drop into Ajv, AJV-CLI, or any modern validator. Object properties are inferred recursively; arrays are typed from their first element. Every property is marked required — remove entries from `required` as needed. Integer vs. number is inferred from the value itself. Everything runs in your browser.

Example

Paste the input on the left and you will get output like this:

Sample JSON

{
  "user": {
    "id": 42,
    "name": "Ada Lovelace",
    "isAdmin": true,
    "roles": ["engineer", "author"]
  }
}

Resulting JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "isAdmin": {
          "type": "boolean"
        },
        "roles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "name",
        "isAdmin",
        "roles"
      ]
    }
  },
  "required": [
    "user"
  ]
}

How to use JSON to JSON Schema

  1. Paste or type your JSON into the left pane.
  2. The JSON Schema appears instantly in the right pane. Conversion runs in your browser — nothing is uploaded.
  3. Copy the result to your clipboard or download it as a file.

FAQ

Which JSON Schema draft?
Draft 2020-12, the latest published draft and the default in Ajv v8+.
Why is every field required?
A single sample cannot express optionality. Prune the `required` arrays after generation to match your real API contract.
How are arrays of mixed types handled?
Only the first element is inspected. For heterogeneous arrays, edit `items` to use `oneOf` or `anyOf` yourself.