JSON schema type mismatches
json-schema-type-mismatches · version 1.0.0 · JSON & JSONL · free, no key needed
List every value whose JSON type fails a JSON Schema 2020-12 "type" keyword, with expected and actual types.
Use when you need to: find wrong types in llm json output · which values have the wrong json type for the schema · list type mismatches with expected and actual type.
Decide before calling
Read the versioned contract and the supported scope below. Reuse json-schema-type-mismatches@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use json-schema-type-mismatches@1.0.0 for find wrong types in llm json output. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- find wrong types in llm json output
- which values have the wrong json type for the schema
- list type mismatches with expected and actual type
- json pointer of every value failing the type keyword
- detect numbers returned as strings in structured output
- is 1.0 an integer under json schema 2020-12
Not supported
- coercing values to the expected type (for example "42" to 42)
- other assertions such as enum, const, minimum, minLength, pattern or format
- schemas using allOf/anyOf/oneOf/not/if/patternProperties/prefixItems, remote or anchor $ref (unsupported_input)
Behavior
- Validation 6.1.1: type is one name or an array of unique names from null, boolean, object, array, number, string, integer; a value passes when its type matches any listed name. An empty type array matches nothing.
- integer matches any number with a zero fractional part, so 1.0 is an integer; number matches every number. The test applies to the IEEE-754 double the value arrives as (JSON text such as 1.0000000000000001 has already become 1). actual reports "integer" for an integer-valued number and "number" otherwise.
- expected lists the keyword's names in schema order (a single string becomes a one-element array). A mismatching value is still traversed: properties, additionalProperties and items keep applying to its children.
- Applicability follows Core 2020-12: properties, additionalProperties as a subschema, items as a single subschema, same-document fragment $ref with sibling keywords, $defs and boolean subschemas. Other keywords are ignored (Core 6.5) except the unsupported applicators, which throw unsupported_input.
- instance_pointer is an RFC 6901 JSON string representation; keyword_location is the evaluation path to the type keyword including "$ref" steps (Core 12.3.1); schema_pointer is that keyword's location in the schema document. Order: pre-order over instance locations (members by ascending UTF-16 code units, elements by index), then schemas in application order.
- count is the total number of failures; at most max_results are listed and truncated is true when count exceeds it; valid is true exactly when count is 0. Lone surrogates in any string or property name, non-finite numbers and non-JSON values throw invalid_input; a $ref cycle with no instance progress throws not_computable.
Input
schema(object or boolean, required): A JSON Schema 2020-12 schema (object or boolean).instance(any JSON value, required): The JSON value to diagnose (any JSON value).
Output
valid(boolean, required)count(integer, required): min 0truncated(boolean, required)mismatches(array of object, required): max items 256
Limits
- max input bytes: 262144
- max depth: 64
- max nodes: 20000
- max schema evaluations: 100000
- max results: 256
- max output bytes: 1048576
Example
Request input:
{
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"instance": {
"age": "42",
"tags": [
"a",
3
]
}
}
Response:
{
"result": {
"valid": false,
"count": 2,
"truncated": false,
"mismatches": [
{
"instance_pointer": "/age",
"expected": [
"integer"
],
"actual": "string",
"keyword_location": "/properties/age/type",
"schema_pointer": "/properties/age/type"
},
{
"instance_pointer": "/tags/1",
"expected": [
"string"
],
"actual": "integer",
"keyword_location": "/properties/tags/items/type",
"schema_pointer": "/properties/tags/items/type"
}
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "json-schema-type-mismatches",
"version": "1.0.0",
"input": {
"schema": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"instance": {
"age": "42",
"tags": [
"a",
3
]
}
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/json-schema-type-mismatches/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"schema":{"type":"object","properties":{"age":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}}}},"instance":{"age":"42","tags":["a",3]}}'
The machine-readable contract is at /v1/tools/json-schema-type-mismatches/versions/1.0.0.
CLI
node cli.mjs run json-schema-type-mismatches 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- JSON schema required missing: List every property a JSON Schema 2020-12 "required" keyword demands but the instance lacks, with JSON Pointers.
- JSON candidate list: Find and rank JSON object/array candidates in prose and Markdown fences (quotes and lists too) with exact raw spans.
- JSON schema additional find: Find every member a JSON Schema 2020-12 "additionalProperties": false forbids, with the member's JSON Pointer.
- JSON schema output validate: Validate JSON (e.g. LLM output) against a Draft 2020-12 schema subset; returns spec output units with JSON Pointers.
- JSON schema batch validate: Validate many JSON records against one Draft 2020-12 subset schema; per-record validity, error pointers, counts.
- JSON fence extract: List Markdown fenced code blocks (CommonMark 0.31.2) with exact spans, unwrapped content and an RFC 8259 JSON check.