What does the JSON Schema Validator do?
The JSON Schema Validator verifies whether target JSON data conforms strictly to predefined Draft-07 or Draft 2020-12 JSON Schema specifications. Powered by the AJV (Another JSON Schema Validator) engine, it performs single-pass schema compilation, enforces structural constraints, and reports schema violations with exact JSONPointer instance paths.
- AJV Draft-07 & Draft 2020-12 Compliance: Validates complex schema vocabularies, including
$defs,prefixItems,oneOf,anyOf,allOf, and format keywords. - Precision JSONPointer Diagnostics: Pinpoints non-conforming nodes (e.g.
/users/0/role) and highlights the corresponding line in red directly in the editor gutter. - 100% In-Browser In-Memory Execution: Performs schema compilation and data validation entirely client-side with zero remote server logging.
Core Concepts & Technical Specifications
- Schema Compilation & JSONPointer Instance Pathing:
- AJV compiles the declarative schema into optimized JavaScript validation functions. When a validation constraint fails, the engine generates an
instancePath(e.g./addresses/0/postalCode) identifying the exact failing key or array element. - Keyword failures specify the constraint violated (
type,required,minimum,format,additionalProperties) alongside runtime parameter values.
- AJV compiles the declarative schema into optimized JavaScript validation functions. When a validation constraint fails, the engine generates an
- Draft-07 vs. Draft 2020-12 Vocabulary Differences:
- Tuple Validation: Draft-07 uses an array under the
itemskeyword for positional tuple checking. Draft 2020-12 standardizesprefixItemsfor positional types and reservesitemsfor the remaining array elements. - Reusable Definitions: Draft-07 uses
definitions, whereas Draft 2020-12 standardizes on$defsand improves dynamic scoping with$dynamicRefand$dynamicAnchor.
- Tuple Validation: Draft-07 uses an array under the
- Format & Boundary Validation Quirks:
- Built-in format validators enforce RFC specifications for
email,date-time(ISO 8601),uri,uuid(RFC 4122), andipv4/ipv6. additionalProperties: falseforbids undeclared keys within its specific scope. For deeply nested structures,additionalProperties: falsemust be declared on each sub-schema level to prevent child object leakage.
- Built-in format validators enforce RFC specifications for
How to use the tool?
- Provide Schema and Data:
- Paste or upload a
.jsonschema definition in the left editor and your target JSON payload in the right editor, or click Sample to load matching test models simultaneously.
- Paste or upload a
- Review Real-Time Gutter Diagnostics:
- Validation triggers automatically on keystroke. If any constraint fails, the specific failing field is highlighted in red in the line-number gutter with a descriptive error report.
- Export Reports:
- Click Download to save the diagnostic validation log as
output.txtor click Copy Report to copy errors directly to your clipboard.
- Click Download to save the diagnostic validation log as
Pipeline & Contextual Workflows
- Syntax Pre-Check Pipeline: Run unverified JSON through JSON Syntax Validator to ensure standard RFC 8259 compliance before applying schema validation rules here.
- Cross-Format Validation: If your configuration is stored in YAML format, evaluate it against your schema using YAML Schema Validator.
- Type Generation: Once your schema is finalized, convert your JSON payload into strongly typed definitions using JSON to TypeScript.
REST API Integration
blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/json/schema) to validate JSON payloads against JSON Schemas programmatically in build pipelines, test suites, and microservices.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
data |
Object / String | Target JSON object or raw JSON string payload to validate. | {"user":"alex_dev","role":"developer"} |
schema |
Object / String | JSON Schema object or raw JSON string defining validation rules. | {"type":"object","required":["user","role"]} |
API Request Payload Examples
cURL (Using Direct JSON Objects)
curl -X POST https://blueutils.com/api/json/schema \
-H "Content-Type: application/json" \
-d '{
"data": {
"user": "alex_dev",
"role": "developer",
"age": 28
},
"schema": {
"type": "object",
"properties": {
"user": { "type": "string", "minLength": 3 },
"role": { "type": "string", "enum": ["admin", "developer", "guest"] },
"age": { "type": "integer", "minimum": 18 }
},
"required": ["user", "role"]
}
}'cURL (Using Raw String Payloads)
curl -X POST https://blueutils.com/api/json/schema \
-H "Content-Type: application/json" \
-d '{
"data": "{\"user\":\"alex_dev\",\"role\":\"developer\",\"age\":28}",
"schema": "{\"type\":\"object\",\"properties\":{\"user\":{\"type\":\"string\"}},\"required\":[\"user\"]}"
}'Python
import requests
url = "https://blueutils.com/api/json/schema"
payload = {
"data": {
"user": "alex_dev",
"role": "developer",
"age": 28
},
"schema": {
"type": "object",
"properties": {
"user": {"type": "string"},
"role": {"type": "string", "enum": ["admin", "developer", "guest"]},
"age": {"type": "integer", "minimum": 18}
},
"required": ["user", "role"]
}
}
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 = """
{
"data": {
"user": "alex_dev",
"role": "developer",
"age": 28
},
"schema": {
"type": "object",
"properties": {
"user": { "type": "string" },
"role": { "type": "string", "enum": ["admin", "developer", "guest"] }
},
"required": ["user", "role"]
}
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/json/schema"))
.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 target data conforms strictly to the schema. | true |
message |
String | Confirmation message returned when validation succeeds. | "Target JSON data strictly conforms to the provided JSON Schema." |
errorCount |
Number | Number of validation errors detected. | 0 |
error |
String | Error summary returned when validation fails. | "Schema validation failed." |
errors |
Array | Array of specific error items containing path, keyword, message, and params. |
[...] |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"message": "Target JSON data strictly conforms to the provided JSON Schema.",
"errorCount": 0
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Schema validation failed.",
"errorCount": 1,
"errors": [
{
"path": "/role",
"keyword": "enum",
"message": "must be equal to one of the allowed values",
"params": {
"allowedValues": ["admin", "developer", "guest"]
},
"schemaPath": "#/properties/role/enum"
}
]
}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 validate JSON schemas?
Programmatic schema validation prevents invalid payloads from corrupting downstream microservices and databases:
- API Gateway Contract Testing: Enforce request/response payloads match OpenAPI or JSON Schema contracts before forwarding to internal services.
- Config Linting in CI/CD: Automatically validate application config files, feature flags, and deployment manifests against central schemas during pull request checks.
- Autonomous Agent Output Verification: Guarantee that structured JSON produced by Large Language Models adheres to strict database insertion schemas.
Native Usage
Visual Studio Code Schema Binding
Map custom JSON Schemas in .vscode/settings.json:
{
"json.schemas": [
{
"fileMatch": ["/config/*.json"],
"url": "./schemas/config.schema.json"
}
]
}Or declare the schema directly inside your JSON file via $schema:
{
"$schema": "./schemas/config.schema.json",
"appName": "blueutils.com",
"port": 8080
}Windows (CMD / PowerShell)
# Using Python jsonschema in PowerShell
python -c "import json, jsonschema; jsonschema.validate(instance=json.load(open('data.json')), schema=json.load(open('schema.json')))"Linux / Unix (Bash)
# Using ajv-cli tool
npx ajv-cli validate -s schema.json -d data.jsonPython
Using jsonschema in Python:
import json
import jsonschema
from jsonschema import validate, ValidationError
with open("schema.json") as sf, open("data.json") as df:
schema = json.load(sf)
data = json.load(df)
try:
validate(instance=data, schema=schema)
print("JSON data conforms to schema successfully.")
except ValidationError as err:
print(f"Validation error at path '{list(err.path)}': {err.message}")Java
Using networknt/json-schema-validator in Java:
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;
import java.io.File;
import java.util.Set;
public class JsonSchemaValidatorExample {
public static void main(String[] args) throws Exception {
ObjectMapper mapper = new ObjectMapper();
JsonNode data = mapper.readTree(new File("data.json"));
JsonNode schemaNode = mapper.readTree(new File("schema.json"));
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);
JsonSchema schema = factory.getSchema(schemaNode);
Set<ValidationMessage> errors = schema.validate(data);
if (errors.isEmpty()) {
System.out.println("JSON data is valid against schema.");
} else {
errors.forEach(e -> System.out.println("Error: " + e.getMessage()));
}
}
}