datapry

JSON Schema Generator

Infer a starting JSON Schema from sample data, with required fields and types filled in. Runs in your browser, so nothing is uploaded.

Draft

JSON sample

JSON Schema

Waiting for input

About this tool

Writing a schema by hand is slow. Paste sample data and get a starting schema with types, nested properties, array items and required fields already filled in. All items of an array are merged, so a field becomes required only if every sample has it.

How to use it

  1. Paste one or more samples as a JSON array.
  2. Choose the draft and whether to mark required fields and allow extra ones.
  3. Copy the schema, then add formats, limits and enums for your real data.

Example

Input
[{"id":1,"name":"Alex"},{"id":2,"name":"Riya","email":"riya@example.com"}]
Output
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "string"
      },
      "email": {
        "type": "string"
      }
    },
    "required": [
      "id",
      "name"
    ]
  }
}

Questions

Is the generated schema ready to use?
It's a starting point. It describes only the samples you gave, so add things the samples can't show, such as formats, string lengths, number ranges and allowed values.
How are integers and decimals handled?
Whole numbers become "integer". If a field has both whole and decimal numbers, it becomes "number".
Can I test data against the result?
Yes. Paste the schema into the JSON Schema Validator with your data to check it.