JSON Schema Generator – Create a Schema from JSON

Paste example JSON and get a JSON Schema (draft 2020-12) with types, required fields and nested objects, ready to use for validation.

JSON Input

Ln 1, Col 1Empty

JSON Schema

Your result will appear here.
No result yet

What Is a JSON Schema Generator?

A JSON Schema describes what valid JSON looks like: which fields exist, their types and which ones are required. Writing a schema by hand takes time. A generator reads an example and writes the schema for you, so you can start validating API requests, config files and test data straight away.

How to Generate a JSON Schema

  1. Paste a typical example of your JSON. More complete examples give better schemas.
  2. Give the schema a title.
  3. Click Generate Schema, or press Ctrl + Enter.
  4. Copy or download schema.json, then fine-tune it if needed.

Features

  • Uses the current standard, JSON Schema draft 2020-12.
  • Detects string, integer, number, boolean, null, arrays and nested objects.
  • Fields missing from some array items are not marked as required.
  • Mixed values become type lists, like ["string", "null"].
  • Runs in your browser. Your JSON is never uploaded.

Example

JSON
{ "id": 1024, "name": "Emily Clark", "email": "emily@example.com", "active": true, "tags": ["admin"] }
Generated schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "User",
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "email": { "type": "string" },
    "active": { "type": "boolean" },
    "tags": { "type": "array", "items": { "type": "string" } }
  },
  "required": ["id", "name", "email", "active", "tags"]
}

Make the Schema Stricter

A generated schema only knows the types in your sample. Add the rules that matter for your data by hand:

Extra rules
"id":    { "type": "integer", "minimum": 1 },
"name":  { "type": "string", "minLength": 2 },
"email": { "type": "string", "format": "email" },
"plan":  { "enum": ["free", "pro", "business"] }

Add "additionalProperties": false to reject unknown fields, and remove names from required if they are optional. Then test real data against it with the JSON Schema Validator. In a TypeScript project, JSON to Zod writes the same kind of checks as a Zod schema.

What JSON Schema Is Used For

  • API validation: reject requests with missing or wrong fields before they reach your code.
  • Documentation: OpenAPI specs describe request and response bodies with JSON Schema.
  • Editor help: VS Code uses schemas to autocomplete and check config files like package.json.
  • Forms and tests: generate forms or test data from one shared definition. For quick random test data, try the JSON Generator.

Frequently Asked Questions

Which JSON Schema version is generated?

The generator writes JSON Schema draft 2020-12, the current version, supported by most validators and API tools.

Will the schema be perfect?

It is a strong starting point based on your example. Add rules the example cannot show, such as minimum values, string formats or enums, by hand.

How are required fields decided?

A field is required when it appears in the example. For arrays of objects, a field is only required if every item has it.

Is my JSON uploaded?

No. The schema is generated in your browser.

Related Tools