>_devtools

JSON to JSON Schema Generator

Generate a JSON Schema from sample JSON: infers types, required properties, string formats, and merged array item shapes.

What this does

Paste a sample JSON document or API response and get a JSON Schema that describes it. It is a quick way to start a schema for an API contract, a config file, or test fixtures; you then tighten it by hand.

How types are inferred

  • Numbers become integer when every sample is a whole number, otherwise number.
  • Arrays: every element is merged into one items schema. Properties that appear in only some elements are listed but not required, and different primitive types combine into a type list such as ["integer", "string"]. Mixed objects and primitives become anyOf.
  • Required: in a single object every present key is required; in an array of objects only keys present in all elements are. Untick the option to leave required out.
  • Formats are added only when every string seen for a property matches:date-time, date, time, email, uuid,uri, or ipv4.
  • null values add null to the type (["string", "null"] when other samples are strings).
  • An empty array becomes "type": "array" with no items, because nothing is known about its elements.

Example

[ { "id": 1, "email": "ada@example.com" },
  { "id": 2, "email": "lin@example.com", "nickname": null } ]

produces:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" },
      "email": { "type": "string", "format": "email" },
      "nickname": { "type": "null" }
    },
    "required": ["id", "email"]
  }
}

Limits of inference

A schema inferred from examples only describes what the examples show. It cannot know that a string must be one of a few values, that a number has a range, or that a key you did not include is allowed. Treat the output as a draft: add enum, minimum, pattern, and descriptions, then check the result with the JSON Schema validator. The input is limited to 5 MB.

Privacy

The schema is generated in your browser. Your JSON is never uploaded or stored.