x402AgentsToolsHub

JSON Repair

Repairs broken JSON: trailing commas, single quotes, unquoted keys, Python literals (True/False/None), NaN, comments, smart quotes and truncated documents. Built for the most common agentic failure mode — parsing slightly-wrong JSON from an LLM or a human.

Worked examples

Trailing comma + single quotes

GET /api/v1/dev/json-repair?text=%7B%20name%3A%20'AgentsToolsHub'%2C%20tools%3A%20%5B91%2C%5D%20%7D

Result: ✓ Repaired (3 defect class(es) detected)

Python literals

GET /api/v1/dev/json-repair?text=%7B%20'ok'%3A%20True%2C%20'count'%3A%20None%20%7D

Result: ✓ Repaired (2 defect class(es) detected)

Commented + unquoted

GET /api/v1/dev/json-repair?text=%7B%20%2F*%20config%20*%2F%20version%3A%202%20%7D

Result: ✓ Repaired (1 defect class(es) detected)

Machine API (x402)

$0.002 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol — no accounts, no API keys.

GET /api/v1/dev/json-repair?text=%7B%20name%3A%20'AgentsToolsHub'%2C%20tools%3A%20%5B91%2C%5D%20%7D HTTP/1.1
Host: agentstoolshub.com

→ 402 (payment required, instructions in headers)
→ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "dev/json-repair",
  "input": {"text":"{ name: 'AgentsToolsHub', tools: [91,] }"},
  "result": { "value": 3, "answer": "✓ Repaired (3 defect class(es) detected)" }
}

Agent docs: /llms.txt · OpenAPI spec · integration guide

About this tool

Deterministically converts almost-JSON into valid JSON and proves the result parses before returning it. Handles the defect classes LLMs actually produce: unquoted keys, single quotes, trailing commas, Python booleans, NaN, comments and truncation. The output is always parseable JSON.

Frequently asked questions

Is the output faithful to the input?

Yes — repair never invents data. Defects are corrected structurally (quotes, commas, literals); values are preserved as written, with undefined → null.

How is this different from a JSON formatter?

A formatter requires valid input. This tool first makes the text parseable, then formats — that's the step agents need before JSON.parse() crashes their pipeline.

Related tools