JSON Schema Generator

JSON Data Input

1

JSON Schema Output

Settings
Auto-generate on input changeEnabled

Generate JSON Schema

Enter your JSON data on the left to automatically generate a corresponding JSON Schema

Supports nested objects and arrays

Auto-detects data types

Generates validation rules

How to generate JSON Schema from JSON – step-by-step guide

Use this online JSON Schema generator to create schema definitions from your JSON sample data for validation, documentation, and API contracts.

  1. Step 1 – Provide your JSON sample

    • Paste a representative JSON object or array into the left editor.
    • Use real production data so the schema accurately reflects your data structure.
    • Include examples of all possible field values and nested structures.
  2. Step 2 – Review the generated schema

    • The schema appears on the right with inferred types, required fields, and structure definitions.
    • Check that array items, nested objects, and property types match your expectations.
    • Verify that optional vs. required fields are correctly identified.
  3. Step 3 – Customize the schema (optional)

    • Copy the generated schema and add custom validation rules, descriptions, or constraints.
    • Add enum values, minLength/maxLength, or pattern regex as needed.
    • Define oneOf or anyOf for union types.
  4. Step 4 – Use the schema

    • Download or copy the schema to use with JSON validators, API documentation tools, or code generators.
    • Integrate with validation libraries like Ajv (JavaScript), jsonschema (Python), or similar tools.
    • Reference the schema in OpenAPI/Swagger specs or use it to generate type-safe code.

Quick tips for schema generation

  • Always validate the generated schema with a JSON validator or your runtime library before using it in production.
  • Use realistic sample data so the online generator can infer correct types and required properties.
  • Keep one canonical schema per payload (e.g. API request/response) to avoid drift between environments.

Schema keyword support note

If you add advanced keywords like $ref, anyOf, oneOf, or allOf, validate with a full JSON Schema validator (for example Ajv) and consider dereferencing the schema before generating mock data.

Example: JSON to JSON Schema
// JSON input
{
  "id": 1,
  "name": "Maeve Winters",
  "email": "maeve@example.com",
  "active": true,
  "tags": ["developer", "backend"]
}

// Generated JSON Schema (simplified)
{
  "type": "object",
  "properties": {
    "id": { "type": "number" },
    "name": { "type": "string" },
    "email": { "type": "string" },
    "active": { "type": "boolean" },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["id", "name", "email", "active", "tags"]
}

Related JSON Schema & validation tools

Use these tools alongside the schema generator to validate, document, and work with JSON data.

Frequently Asked Questions

What is a JSON Schema?

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It provides a contract for what JSON data is required for a given application and how to interact with it.

How do I generate a schema from my JSON data?

Simply paste your JSON data into the input editor. The schema will be automatically generated based on your data structure, including data types, required fields, and patterns.

What information is included in the generated schema?

The generated schema includes data types, required properties, property descriptions, array item definitions, object structure, and validation constraints based on your JSON data patterns.

Can I customize the generated schema?

Yes! After generation, you can copy the schema and modify it to add additional constraints, descriptions, or validation rules as needed for your specific use case.

JSON Schema Generator - Create Schema From JSON | JSONSwiss