JSON to JSON Schema

Infer a formal, standards-compliant JSON Schema (Draft-07, Draft-2020-12, or Draft-04) from any sample JSON document. Automatically detect property types, string formats, arrays, and required fields.

How to Generate JSON Schema from JSON Online

1

Input JSON Payload

Paste your sample JSON document into the left editor, click Upload to load a `.json` file, or click Sample.

2

Configure Schema Draft

Choose your target draft version (Draft-07, Draft 2020-12, or Draft-04) and customize required fields rules.

3

Export Schema

Schema generates automatically in real time. Click Copy or Download to export your generated `output.json`.

Tool Options

Multi-Draft Compatibility

Generates official schema definitions conforming to Draft-07, Draft 2020-12, or legacy Draft-04 with correct $schema URIs.

Automatic String Format Detection

Automatically identifies string semantics including date-time, date, email, uri, ipv4, and uuid.

Deep Heterogeneous Array Merging

Recursively merges object schemas across all array records to ensure every potential property is represented in the output definition.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the JSON to JSON Schema Generator do?

The JSON to JSON Schema Generator infers a formal, standards-compliant JSON Schema (Draft-07, Draft 2020-12, or Draft-04) from any sample JSON data payload in real time. Executing 100% in-browser on blueutils.com, it inspects primitive types (strings, numbers, integers, booleans, and null), analyzes multidimensional object structures, merges heterogeneous array record definitions, and automatically detects semantic string formats (date-time, date, email, uri, ipv4, and uuid).

  • Real-Time Zero-Latency Schema Inference: Generates JSON Schema definitions as you type with instant syntax validation and error gutter location.
  • Specification Draft Flexibility: Switch seamlessly between Draft-07, Draft 2020-12, and legacy Draft-04.
  • Deep Heterogeneous Array Merging: Recursively unions properties across all objects in an array, marking commonly shared properties as required.

Core Concepts & Technical Specifications

  1. Structural Type Inference:
    • Maps JavaScript/JSON primitives to standard JSON Schema types: string, integer, number, boolean, array, object, and null.
  2. String Format Detection:
    • Automatically identifies semantic patterns:
      • date-time: ISO 8601 timestamps (2026-08-23T08:00:00Z).
      • date: Calendar dates (YYYY-MM-DD).
      • email: RFC 5322 email addresses (user@domain.com).
      • ipv4: Quad-dotted IPv4 addresses (192.168.1.1).
      • uri: Protocol URLs (https://blueutils.com).
      • uuid: Canonical RFC 4122 UUID strings (123e4567-e89b-12d3-a456-426614174000).
  3. In-Browser Privacy:
    • All schema inference algorithms execute locally in browser memory.
    • No data is transmitted to external servers, logged, or retained.

How to use the tool?

  1. Input Sample JSON:
    • Paste your sample JSON document into the left editor, click Upload to load a local .json file, or click Sample.
  2. Configure Draft & Options:
    • Choose your target JSON Schema draft (Draft-07, Draft 2020-12, or Draft-04), customize indentation (2 Spaces, 4 Spaces, or Tabs), and set required field modes (All Required or Optional Keys).
  3. Copy or Download:
    • Schema appears instantly in the right editor. Click Copy to copy to your clipboard or Download to save as output.json.

Pipeline & Contextual Workflows

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/json/to-jsonschema) for automated CI/CD schema generation, contract testing, and data pipelines.

API Request Parameters

Name Type Description Example
rawText / json String / Object Sample JSON payload string or parsed JavaScript object. "{\"userId\": 101, \"email\": \"user@example.com\"}"
draft String Target draft: "draft-07" (default), "draft-2020-12", or "draft-04". "draft-07"
requiredFields Boolean Include "required" property arrays (default: true). true
detectFormats Boolean Automatically detect date-time, email, uri, uuid (default: true). true
indent Number / String Indentation spaces (e.g. 2, 4, or "tab"). Defaults to 2. 2

API Request Payload Examples

cURL (Using Direct JSON Object)

curl -X POST https://blueutils.com/api/json/to-jsonschema \
  -H "Content-Type: application/json" \
  -d '{
    "json": {
      "userId": 101,
      "email": "user@example.com",
      "active": true
    },
    "draft": "draft-07",
    "requiredFields": true,
    "detectFormats": true,
    "indent": 2
  }'

Python

import requests

url = "https://blueutils.com/api/json/to-jsonschema"
payload = {
    "json": {
        "userId": 101,
        "email": "user@example.com",
        "active": True
    },
    "draft": "draft-07",
    "requiredFields": True,
    "detectFormats": True,
    "indent": 2
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "json": {
                    "userId": 101,
                    "email": "user@example.com"
                },
                "draft": "draft-07",
                "requiredFields": true
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/json/to-jsonschema"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether the schema generation succeeded. true
draft String Draft version used for generated schema. "draft-07"
schema / result String Formatted JSON Schema string output. "{\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n...}"
schemaObject / data Object Parsed JavaScript JSON Schema object representation. { "$schema": "...", "type": "object" }
originalSize Number Byte size of raw input payload in UTF-8. 45
schemaSize Number Byte size of generated JSON Schema in UTF-8. 185
error String Detailed error explanation returned on invalid syntax. "Invalid JSON syntax: Unexpected token '}' (Line 2)"

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "message": "JSON Schema (draft-07) generated successfully.",
  "draft": "draft-07",
  "schema": "{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"title\": \"Generated Schema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"userId\": {\n      \"type\": \"integer\"\n    },\n    \"email\": {\n      \"type\": \"string\",\n      \"format\": \"email\"\n    }\n  },\n  \"required\": [\n    \"userId\",\n    \"email\"\n  ]\n}",
  "result": "{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"title\": \"Generated Schema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"userId\": {\n      \"type\": \"integer\"\n    },\n    \"email\": {\n      \"type\": \"string\",\n      \"format\": \"email\"\n    }\n  },\n  \"required\": [\n    \"userId\",\n    \"email\"\n  ]\n}",
  "schemaObject": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Generated Schema",
    "type": "object"
  },
  "data": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Generated Schema",
    "type": "object"
  },
  "originalSize": 45,
  "schemaSize": 185,
  "nodeCount": 2
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Invalid JSON syntax: Unexpected token '}' at position 15 (Line 1, Column 16)"
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to generate JSON Schema?

Automating JSON Schema inference accelerates API lifecycle management:

  • Automated Contract Ingestion: Infers schemas from live microservice response snapshots during integration tests.
  • LLM Context Optimization: Offloads schema synthesis from prompt instructions, generating valid Draft-07 schemas deterministically.
  • Fast Mock Validation: Seeds JSON Schema Validator engines without manually authoring verbose $schema trees.

Native Usage

Infer JSON Schemas locally across terminal environments and programming runtimes:

Linux / macOS (npx quicktype)

# Generate JSON Schema using quicktype CLI
npx quicktype -s schema -l schema input.json -o output.json

Windows (PowerShell)

# Generate JSON Schema in PowerShell using Python genson
python -c "import genson, json, sys; b = genson.SchemaBuilder(); b.add_schema({'$schema': 'http://json-schema.org/draft-07/schema#'}); b.add_object(json.load(sys.stdin)); print(b.to_json(indent=2))" < input.json > output.json

Python

from genson import SchemaBuilder
import json

sample_data = {
    "userId": 101,
    "username": "alex_dev",
    "email": "alex@example.com",
    "isActive": True
}

builder = SchemaBuilder()
builder.add_schema({"$schema": "http://json-schema.org/draft-07/schema#"})
builder.add_object(sample_data)

schema = builder.to_json(indent=2)
print(schema)

Java (Jackson)

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;

public class Main {
    public static void main(String[] args) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
        JsonSchema schema = schemaGen.generateSchema(Object.class);
        System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema));
    }
}

Frequently Asked Questions (FAQ)

How does the JSON to JSON Schema Generator infer property types?

The generator inspects JavaScript data types and values in your sample JSON document, mapping strings, numbers, integers, booleans, objects, nulls, and array sequences into their corresponding JSON Schema keywords.

Which JSON Schema draft specifications are supported?

We support Draft-07 (ideal for Ajv and OpenAPI 3.0), Draft 2020-12 (the modern standard supporting dynamic references), and legacy Draft-04.

How does the generator handle arrays with multiple differing objects?

The generator deeply merges all object keys across array items, producing a unified properties dictionary and marking properties present in every item as required.

Can I automatically detect string formats like dates, emails, and UUIDs?

Yes. The generator checks string values against regex patterns to automatically assign format: date-time, date, email, uri, ipv4, and uuid constraints.

Is my sample JSON data uploaded to a remote server?

No. All schema inference and JSON parsing execute 100% client-side directly inside your browser engine. Your JSON data never leaves your computer.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.