Skip to main content
Glama

JSON Repair API - fix broken LLM JSON, validate schema

json_repair_validate
Read-onlyIdempotent

Your model returned almost-JSON? Send the raw text, get valid JSON back plus the list of every fix. No extra key or account needed. Handles ```json fences and chatty text around the JSON, trailing or missing commas, single and smart quotes, unquoted keys, comments, Python True/None, NaN, raw newlines in strings and output cut off mid-string (closed cleanly). Optional JSON Schema (draft 2020-12/2019-09/07) check with exact error paths, plus safe coercion ("42" -> 42, "true" -> true, value -> [value]). Nothing stored, ~1-25 ms. For AI agents, LLM apps, n8n/Make flows and backend payload checks. Free: 5 calls/day per IP. Paid: Radar API key (from €9/mo at https://radarbg.com/pricing#starter via X-API-Key) or $0.001/call via x402 at https://radarbg.com/x402/json-repair-validate.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "json": "Sure! Here it is:\n```json\n{'name': 'Ada', tags: [\"math\", \"code\",], active: True, // note\n \"bio\": \"First programmer, see http://x.com//ada\", \"born\": \"1815\"",
      "schema": {
        "type": "object",
        "required": [
          "name",
          "born"
        ],
        "properties": {
          "born": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "name": "json_repair_validate"
  }
}

Input Schema

NameRequiredDescriptionDefault
jsonNoThe broken JSON text (or the whole model answer with prose around it), max 1,000,000 chars
coerceNoWith a schema: cast obvious type mismatches ("12" -> 12, "true" -> true, value -> [value]) and list each cast as a fix
schemaNoOptional JSON Schema to validate the repaired data against (object or JSON string; remote $ref not fetched)
extractNoWhich JSON block to take when the text holds several: first, largest or allfirst

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the readOnly/openWorld/idempotent annotations, the description discloses cost and access behavior in detail: 5 free calls/day per IP, paid via X-API-Key or x402 at $0.001/call, no account needed, nothing stored, and a ~1-25 ms latency envelope. It also warns that remote $ref is not fetched during schema validation, which is behavior an agent cannot infer from the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The payload is front-loaded: the problem and the return shape come first, mechanics second, and pricing last. It is dense but every early sentence carries information; the audience list ("For AI agents, LLM apps, n8n/Make flows") and the two URLs are the only promotional weight that does not help an agent invoke the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description carries the return-value burden and does so by specifying valid JSON plus an itemized list of fixes and exact schema error paths. It also covers input scope (1,000,000 char max, prose tolerated), truncation recovery, and the absence of remote $ref fetching — nothing material for a correct call is left out.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description earns above that by explaining the practical semantics of coercion with concrete mappings ("42"->42, "true"->true, value->[value]) and by naming the supported schema drafts (2020-12/2019-09/07), which the schema itself does not state. The extract modes (first/largest/all) are also framed as the rule for multi-block text rather than just an enum.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a concrete verb+resource pair — take almost-JSON text and return valid JSON plus the list of fixes — and enumerates the exact failure modes it handles (fences, trailing commas, smart quotes, unquoted keys, Python literals, NaN, truncation). That makes the tool unmistakable in intent, though it never contrasts itself with the sibling json_formatter, which an agent would also consider for malformed JSON.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

"Your model returned almost-JSON?" plus the target audience list (AI agents, LLM apps, n8n/Make flows, backend payload checks) gives a clear selection context. What is missing is an explicit exclusion or an alternative named by role — nothing tells the agent when to prefer json_formatter or plain parsing instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources