JSON to JSON Schema Converter

Automatically produce a draft-07 JSON Schema from any JSON value, with types, nested object definitions, and array item schemas all inferred from your sample data. You can set a schema title and description, mark all detected fields as required, disable additionalProperties, and embed example values — all with individual toggles. The converter accepts plain JSON or newline-delimited JSONL and runs entirely in your browser without sending any data to a server.

Input

JSON

Schema Info

Validation

Indent Style

1 rows, 7 columns
Output

JSON Schema

What is JSON to JSON Schema Generator?

JSON Schema is the contract between your API and its consumers — it defines which fields are required, what types are acceptable, and what formats are valid. Writing one from scratch is tedious; inferring it from a JSON sample is something a tool should do. Paste a representative JSON object or array and get a complete JSON Schema document (draft-07, draft-2019-09, or draft-2020-12) with type, properties, and required arrays correctly populated. Fields present in every sample object are marked required; fields appearing as null are typed with a null union. Enable string format detection to automatically add "format": "email", "format": "date-time", or "format": "uri" hints for recognisable patterns. The output integrates directly with ajv for Node.js validation, Postman schema validation, OpenAPI 3.0 component schemas, and Zod/Yup schema bootstrapping.

How to Use

  1. 1

    Paste Your JSON Sample

    Paste a representative JSON object or array. Use a sample that contains all expected field types — null, string, number, boolean, array, nested object — for the most accurate schema generation.

  2. 2

    Configure Schema Options

    Choose the JSON Schema draft version (draft-07, draft-2019-09, draft-2020-12), set the root schema title and description, enable required field detection, and choose whether to add format hints (email, uri, date-time) for string fields.

  3. 3

    Generate the Schema

    Click "Generate Schema". The tool infers types from all values, marks fields as required if they appear in every sample object, and produces a complete JSON Schema document with $schema, type, properties, and required arrays.

  4. 4

    Copy or Download the Schema

    Copy the JSON Schema for use in API gateway validation, ajv/Zod integration, OpenAPI spec, or documentation generation — or download it as a .json or .schema.json file.

Common Use Cases

API Request Validation

Generate a JSON Schema from a sample request payload to use in API gateways (AWS API Gateway, Kong), Express middleware (ajv), or FastAPI to validate incoming request bodies before processing.

Documentation Generation

Auto-generate JSON Schema from sample API responses to publish as machine-readable API documentation, feed into Swagger/OpenAPI specs, or use with tools like json-schema-to-markdown.

Form Validation with Zod / Yup

Derive a JSON Schema from your data model JSON and use it as the basis for Zod or Yup validation schemas in React forms, ensuring runtime validation matches your data structure.

Database Schema Inference

Generate a JSON Schema from a NoSQL document sample (MongoDB, Firestore) to document the implicit schema of your collection and enforce it via schema validation rules at the database level.

Conversion Examples

JSON Object → JSON Schema (draft-07)

Types, required fields, and nested objects are inferred automatically.

Input JSON

{
  "id": 1,
  "name": "Alice",
  "email": "alice@example.com",
  "isPremium": true,
  "score": 98.5
}

Output CSV

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["id", "name", "email", "isPremium", "score"],
  "properties": {
    "id":        {"type": "integer"},
    "name":      {"type": "string"},
    "email":     {"type": "string"},
    "isPremium": {"type": "boolean"},
    "score":     {"type": "number"}
  }
}

Nested JSON → Nested Schema with $defs

Nested objects generate $defs references for reusable schema components.

Input JSON

{
  "user": {"id": 1, "name": "Alice"},
  "orders": [{"id": 101, "total": 49.99}]
}

Output CSV

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "id": {"type": "integer"},
        "name": {"type": "string"}
      }
    },
    "orders": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {"type": "integer"},
          "total": {"type": "number"}
        }
      }
    }
  }
}

Frequently Asked Questions