JSON Schema Generator

Generates a JSON Schema (draft 2020-12) from a sample JSON document. Integers and decimals are told apart, nested objects are lifted into $defs and referenced, and a list of records is described as an array so the schema validates the document it came from. Paste an array of records and keys missing from some of them are left out of "required". Runs entirely in your browser — nothing is sent to a server.

Ad placeholder: Resp_Horizantal_1 (horizontal)
Ad placeholder: Resp_Square_1 (square)

Generates a JSON Schema (draft 2020-12) from a sample JSON document. Integers and decimals are told apart, nested objects are lifted into $defs and referenced, and a list of records is described as an array so the schema validates the document it came from. Paste an array of records and keys missing from some of them are left out of "required". Runs entirely in your browser — nothing is sent to a server.

Use cases

  • Bootstrapping a contract for an API that has none
  • Generating a schema to validate config files against

Examples

Simple object

{"id":1,"name":"Ada"}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name"
  ]
}

FAQ

Is my data sent to a server?

No — this tool runs entirely in your browser.

How is required decided?

A key is required when it appears in every record of the sample. Paste several representative records to get this right — one record makes every key look required.

What happens to an empty array?

Its items are left unconstrained, since a sample with no elements says nothing about what they contain.