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
- Structural Type Inference:
- Maps JavaScript/JSON primitives to standard JSON Schema types:
string,integer,number,boolean,array,object, andnull.
- Maps JavaScript/JSON primitives to standard JSON Schema types:
- 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).
- Automatically identifies semantic patterns:
- 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?
- Input Sample JSON:
- Paste your sample JSON document into the left editor, click Upload to load a local
.jsonfile, or click Sample.
- Paste your sample JSON document into the left editor, click Upload to load a local
- 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).
- Copy or Download:
- Schema appears instantly in the right editor. Click Copy to copy to your clipboard or Download to save as
output.json.
- Schema appears instantly in the right editor. Click Copy to copy to your clipboard or Download to save as
Pipeline & Contextual Workflows
- Schema Validation: Validate production request bodies against the inferred schema using the JSON Schema Validator.
- TypeScript Generation: Generate typed interfaces from JSON structures using JSON to TypeScript Converter.
- Data Restructuring: Flatten nested JSON payloads before schema generation with JSON Flatten Tool.
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
$schematrees.
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.jsonWindows (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.jsonPython
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));
}
}