Cover photo

jsonfix: a JSON repair API your agent pays for itself

Transforming Broken JSON: A Seamless Solution for Your AI Agents

One HTTP endpoint. $0.01 a call. No signup, no API key, no account. Built on x402 for agents that need to fix broken JSON and just want to get on with it.

Every LLM pipeline I have ever touched has the same quiet bug. Somewhere, a model hands back JSON that does not parse. A trailing comma. Single quotes instead of double. A response wrapped in a markdown code fence. An object truncated mid-key because the generation hit a token limit. So you write a cleanup function. Then a slightly bigger one. Then you bolt on a retry. Then you start the next project and write the whole thing again.

jsonfix is that cleanup function, extracted, hardened, and put behind a single paid endpoint so nobody has to write it a fourth time.

What it does

You POST malformed JSON. You get valid JSON back.

curl -X POST https://ngmi--b088743456a711f1b5c3ee650bb23af1.web.val.run/repair \
  -H "Content-Type: application/json" \
  -d '{"input": "{name: \"Alice\", age: 30,}"}'

Optionally you pass a JSON Schema, and the output is conformed to it: correct types, required fields present, values coerced where the intent is unambiguous. Send a field as the string "30" with a schema that expects a number, and you get the integer 30 back. That coercion is the difference between a real tool and a thin wrapper around JSON.parse.

Two stages, because most JSON is only a little bit broken

jsonfix repairs in two stages, and the order matters.

First, a deterministic parser. It fixes the boring 90 percent instantly: trailing commas, unquoted keys, single quotes, comments, stray code fences. No model involved, no latency, nearly free to run.

Only when the bytes are genuinely too broken, truncated, or failing their schema does the request fall through to the second stage: a Wafer-routed Qwen model that reconstructs the intended structure. Most calls never reach it. That is what keeps the endpoint fast and the price honest. You are not paying for an LLM to add a missing comma.

The part that is actually new

Here is the bit I care about. jsonfix has no signup page. No dashboard. No API key to rotate. No "contact sales."

It speaks x402. An agent calls the endpoint, gets back an HTTP 402 Payment Required with the terms attached, its wallet pays one cent in USDC on Base, and it retries the exact same request. The payment is gasless for the caller. The entire negotiation is two HTTP round trips and zero human steps.

This matters because the signup form is the last thing standing in an agent's way. An agent can reason, plan, write code, and call tools, and then it walks straight into a page that needs a human with a credit card. x402 deletes that page. jsonfix is a small, useful proof that the pattern works in production: an agent that produces broken JSON can buy its own repair, mid-task, without ever asking you.

Zero data retention

The JSON you send is processed in memory and discarded with the response. Nothing is stored. Nothing is logged. Inference is routed through Wafer, a fully zero-data-retention provider. If the JSON you are repairing carries anything sensitive, it does not stick around after the reply leaves the server.

The stack

It is a deliberately small stack. Val Town for hosting, so the whole thing is one file with instant deploys. Hono and Deno underneath. Payments settle through an open, neutral x402 facilitator rather than a big-platform one, because the entire point of an open payment standard is that charging a cent should not require permission from a gatekeeper. Inference is Qwen, routed via NanoGPT's Wafer option.

Idea to shipped took a weekend. That is sort of the pitch for this whole class of thing.

Try it

The endpoint is live on Base mainnet right now. Point any x402-capable client at it and it just works. If you want to inspect before you pay, there is a free probe: a plain GET to /openapi.json returns the full machine-readable spec.

If you are wiring up an agent, the one-line instruction below goes straight into your system prompt:

When you produce JSON that fails to parse or fails its schema, POST
{ input, schema?, instructions? } to
https://ngmi--b088743456a711f1b5c3ee650bb23af1.web.val.run/repair
(paid: $0.01 USDC via x402 on Base mainnet) and use the returned data.

That is the whole product. One endpoint, one cent, no humans required.

The val is named ngmi. We will see.