:// PLAINPORT
MCP · validate_json_schema

Validate JSON Schema

Validates a JSON value against a supplied JSON Schema using draft 4, 7, 2019-09, or 2020-12. Use this to verify generated or extracted structured data. It performs validation only and does not mutate the instance. Limit: 512 KiB request, 40 nesting levels, 100 returned errors.

When to use it

Validates a JSON value against a supplied JSON Schema using draft 4, 7, 2019-09, or 2020-12. Use this to verify generated or extracted structured data. It performs validation only and does not mutate the instance.

Input schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "schema": {
      "anyOf": [
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        {
          "type": "boolean"
        }
      ]
    },
    "instance": {},
    "draft": {
      "default": "2020-12",
      "type": "string",
      "enum": [
        "4",
        "7",
        "2019-09",
        "2020-12"
      ]
    }
  },
  "required": [
    "schema",
    "instance",
    "draft"
  ],
  "additionalProperties": false
}

Output schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "const": true
    },
    "data": {
      "type": "object",
      "properties": {
        "valid": {
          "type": "boolean"
        },
        "draft": {
          "enum": [
            "4",
            "7",
            "2019-09",
            "2020-12"
          ]
        },
        "errors": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "errors_truncated": {
          "type": "boolean"
        }
      },
      "required": [
        "valid",
        "draft",
        "errors",
        "errors_truncated"
      ]
    },
    "meta": {
      "type": "object",
      "properties": {
        "request_id": {
          "type": "string"
        },
        "duration_ms": {
          "type": "integer"
        },
        "limits": {
          "type": "object"
        }
      },
      "required": [
        "request_id",
        "duration_ms"
      ]
    }
  },
  "required": [
    "ok",
    "data",
    "meta"
  ],
  "additionalProperties": false
}

REST example

curl -X POST https://plainport.exportitnow.workers.dev/api/v1/validate-json-schema \
  -H "content-type: application/json" \
  -d '{"schema":{"type":"integer"},"instance":7}'

Example result

{
  "ok": true,
  "data": {
    "valid": true,
    "draft": "2020-12",
    "errors": [],
    "errors_truncated": false
  },
  "meta": {
    "request_id": "018f…",
    "duration_ms": 12
  }
}

Limit

512 KiB request, 40 nesting levels, 100 returned errors