# JSON Repair API

> JSON Repair API is a paid API for AI agents from preflight.agentdiet.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-11-20).

Repairs and normalizes malformed or invalid JSON strings into valid, well-formed JSON objects.

## Facts

- Endpoint: GET https://preflight.agentdiet.dev/v1/json-repair?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-20
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/json-repair-api-5ca2bd15
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_QZb_muKTQpD3kgr1IAgWd

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability json-repair-api-5ca2bd15
```

Example prompt: Can you fix this broken JSON for me? It has missing quotes and a trailing comma and I need it to be valid so I can parse it: {name: 'Alice', age: 30,}

## When to prefer this

Choose this endpoint when you need a fast, cheap ($0.002 USDC) automated fix for malformed, truncated, or syntactically invalid JSON — especially useful for cleaning LLM-generated JSON, recovering partial API responses, or normalizing user-submitted config data. Best when you have a raw string that is JSON-like but fails standard parsers.

## Known failure modes

- Input JSON is so corrupted it cannot be inferred or repaired — returns error status
- Missing required 'input' parameter returns schema validation error
- Input that is not JSON-like at all (e.g. plain text or binary) may fail to parse
- Extremely large or deeply nested JSON may hit payload size limits

## How this service works

Automated 8-gate pre-flight readiness auditor for x402 v2, Dexter gas floor, IETF MPP, MCP Streamable HTTP, A2A v0.3.0 agent cards, OASF records, and ERC-8004 identity.

## Output

Returns a JSON object with a 'data' field containing the repaired valid JSON, a 'status' field indicating success or failure, and an 'roi_proof' object showing the compression_ratio_pct achieved during repair/normalization (e.g. 91.4%).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "POST"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "properties": {
      "raw_json": {
       "type": "string"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "data": {},
  "status": "ok",
  "roi_proof": {
   "compression_ratio_pct": 91.4
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/json-repair-api-5ca2bd15/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from preflight.agentdiet.dev](https://www.zero.xyz/host/preflight.agentdiet.dev/llms.txt)
