JSON to JSON Schema Generator

: Infer a JSON Schema from sample data and edit its attributes visually
Limits: 50 MB · JSON Schema draft 2020-12. After generation, sample changes only update validation; your schema edits stay. Large numbers use JavaScript precision.
JSON Schema
Generate a schema to inspect its fields.

Turn example data into a draft 2020-12 schema, then select fields in a tree to refine their types, annotations and constraints. Use it to draft an API contract or a validation rule set when you have representative JSON but no schema yet.

  1. Put data in the JSON sample pane: type it, press Paste (or Ctrl+V anywhere on the page), press Open file or drop a file, or press Example.
  2. Press Generate schema. The tree shows inferred fields, types and required properties.
  3. Select a field, edit its attributes and press Apply attributes. Required property controls presence; nullable controls whether its value may be null.
  4. Review the validation results under the attributes. Change the sample to test other values without overwriting your schema edits.
  5. Switch to Source to inspect the JSON, then Copy it or Download schema.json. Regenerate schema starts again from the current sample and replaces your edits.

Both array entries contribute fields; note is optional because only one entry includes it.

Input
[{"id":1,"note":"Gift"},{"id":2}]
Output
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer"
      },
      "note": {
        "type": "string"
      }
    },
    "required": [
      "id"
    ]
  }
}

Does changing my JSON sample regenerate the schema?

No. Sample edits only rerun validation against the current schema. Press Regenerate schema when you want to replace it with a new inference.

Can a required property also be nullable?

Yes. Required means the key must be present; nullable allows its value to be null. For example, a required nullable string accepts a present null value but rejects an absent property.

Runs entirely in your browser. Nothing is uploaded.