JSON Schema API
Validate JSON against a JSON Schema or generate a draft 2020-12 schema from sample data. Detailed error paths, format detection, free and browser-based.
The JSON Schema is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/json-schema — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
mode | "validate" | "generate" | required | validate: check an instance against a schema. generate: infer a draft 2020-12 schema from a sample document. |
instance | string | required | The JSON document to validate (max 1 MB in validate mode) or to infer a schema from (max 5 MB in generate mode). |
schema | string | optional | Required in validate mode: the JSON Schema (draft 2020-12) as JSON text, max 1 MB. Local $refs only; remote refs are never fetched. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
mode | "validate" | "generate" | required | The mode that was executed. |
valid | unknown | required | Validate mode: whether the instance conforms. format-keyword failures do not affect this. |
schemaError | unknown | required | Validate mode: why the schema itself could not be used (invalid JSON, uncompilable, unresolved remote $ref). |
errors | object[] | required | Validate mode: instance-validation errors, capped at 100 entries. |
errorCount | unknown | required | Validate mode: total instance-validation errors before the cap. |
formatWarnings | object[] | required | Validate mode: format-keyword failures, reported as annotations only (capped at 100). |
schema | unknown | required | Generate mode: the inferred draft 2020-12 schema, pretty-printed. |
Example request
curl -X POST https://dot.tools/api/tools/json-schema \
-H 'Content-Type: application/json' \
-d '{
"mode": "generate",
"instance": "{\n \"id\": \"3f6b0f5e-8c1d-4a2b-9e7c-1d2f3a4b5c6d\",\n \"name\": \"Ada Lovelace\",\n \"email\": \"ada@analytical.engineer\",\n \"created_at\": \"1843-09-09T12:30:00Z\",\n \"website\": \"https://example.com/ada\",\n \"level\": 9,\n \"score\": 98.5,\n \"active\": true,\n \"address\": {\n \"city\": \"London\",\n \"zip\": \"EC1\"\n },\n \"roles\": [\n \"engineer\",\n \"mathematician\"\n ],\n \"nickname\": null\n}"
}'Sample response
{
"ok": true,
"result": {
"mode": "generate",
"valid": null,
"schemaError": null,
"errors": [],
"errorCount": null,
"formatWarnings": [],
"schema": "{\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"type\": \"object\",\n \"properties\": {\n \"active\": {\n \"type\": \"boolean\"\n },\n \"address\": {\n \"type\": \"object\",\n \"properties\": {\n \"city\": {\n \"type\": \"string\"\n },\n \"zip\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"city\",\n \"zip\"\n ]\n },\n \"created_at\": {\n \"type\": \"string\",\n \"format\": \"date-time\"\n },\n \"email\": {\n \"type\": \"string\",\n \"format\": \"email\"\n },\n \"id\": {\n \"type\": \"string\",\n \"format\": \"uuid\"\n },\n \"level\": {\n \"type\": \"integer\"\n },\n \"name\": {\n \"type\": \"string\"\n },\n \"nickname\": {\n \"type\": \"null\"\n },\n \"roles\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"score\": {\n \"type\": \"number\"\n },\n \"website\": {\n \"type\": \"string\",\n \"format\": \"uri\"\n }\n },\n \"required\": [\n \"active\",\n \"address\",\n \"created_at\",\n \"email\",\n \"id\",\n \"level\",\n \"name\",\n \"nickname\",\n \"roles\",\n \"score\",\n \"website\"\n ]\n}"
}
}Use the free JSON Schema in your browser, read the JSON Schema guide, or import the full OpenAPI specification.