# JSON Repair & Parse for LLM Output

> JSON Repair & Parse for LLM Output is a paid API for AI agents from api.x402node.dev, paid per call via x402, $0.006/call, status unknown (last checked 2026-09-14).

Deterministically repairs and parses malformed JSON from LLM output, fixing trailing commas, single quotes, unquoted keys, markdown fences, comments, and Python literals

## Facts

- Endpoint: POST https://api.x402node.dev/ai/json-repair
- Price: $0.006/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/json-repair-parse-for-llm-output-d3df4f2b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_RgS97XGDJX58X_WeSo3uS

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-parse-for-llm-output-d3df4f2b -d '<json body>'
```

Example prompt: The JSON I got back from the LLM has trailing commas, markdown fences, and single quotes — can you repair and parse it into valid structured data? Here's the broken string: ```json {'name': 'Alice', 'scores': [1, 2, 3,],}```

## When to prefer this

Use this endpoint when handling LLM-generated JSON that frequently contains common syntax errors like trailing commas, single-quoted strings, unquoted keys, embedded markdown code fences, JavaScript comments, or Python-style literals (True/False/None). It is especially suited for production pipelines that consume raw LLM output and need reliable, deterministic parsing without writing custom sanitization logic. Prefer it over manual regex cleaning or ad-hoc parsers when you need a robust, maintained repair solution.

## Known failure modes

- Input is so malformed it cannot be salvaged into any valid JSON structure — returns error indicating unrecoverable input
- Input is not JSON-like at all (e.g. plain prose with no JSON tokens) — may return error or unexpected result
- Ambiguous repair heuristics may occasionally produce a different valid structure than intended when multiple repair paths exist
- Payment failure or insufficient USDC balance results in 402 response before any processing occurs

## How this service works

Deterministically repair malformed JSON from LLM output - fixes trailing commas, single quotes, unquoted keys, markdown fences, comments and Python literals, returning parsed data. json repair, fix json, parse llm json, broken json, json fixer, malformed json

## Output

Returns the repaired and fully parsed JSON as structured data (object or array), ready for programmatic consumption — no longer a raw string, but an actual parsed result with all syntax errors resolved

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "json": {
   "type": "string",
   "description": "The broken JSON string to repair (required, max 500KB)"
  },
  "text": {
   "type": "string",
   "description": "Input text (optional)"
  },
  "input": {
   "type": "string",
   "description": "Input (optional)"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/json-repair-parse-for-llm-output-d3df4f2b/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.x402node.dev](https://www.zero.xyz/host/api.x402node.dev/llms.txt)
