obfus.link

LLM to JSON Cleaner repairs malformed JSON returned by language models. It strips markdown code fences, trailing commas, and comments, then validates against an optional JSON Schema. Aggressive mode infers missing closing brackets in truncated outputs. Returns a 0-1 repair confidence score so agents can decide whether to auto-accept the result or escalate to a human reviewer.

Tier 3converters✓ TDD Verified

LLM to JSON Cleaner

Repair malformed JSON from LLM responses with confidence scoring

Strips markdown fences, // and /* */ comments, and trailing commas.

Returns json: null with low confidence if unparseable.

How to use

  1. Paste raw LLM outputDrop in the unparsed string with markdown fences, comments, or trailing commas.
  2. Choose repair strategyConservative strips fences and commas. Aggressive also infers missing closing brackets.
  3. Add a target schema (optional)Provide a JSON Schema object for one-call validation alongside repair.
  4. Check repair confidenceA score of 1.0 means only whitespace was changed. Below 0.5 means structural repairs occurred.
  5. Inspect transformationsEach repair is logged with type, description, and position so you can audit the changes.
Read technical article

MCP / API

Call llm_to_json_cleaner directly from any MCP-compatible agent:

// MCP TypeScript SDK
const result = await client.callTool({
  name: "llm_to_json_cleaner",
  arguments: {
    "raw": "..."
  }
});

// curl
curl -X POST https://obfus.link/mcp \
  -H "Authorization: Bearer <SPT>" \
  -H "Content-Type: application/json" \
  -d '{"method":"tools/call","params":{"name":"llm_to_json_cleaner","arguments":{"raw":"..."}}}'

Related tools

JSON to Zod
Generate Zod schemas with JSDoc and branded types from any JSON
JWT Hardener
Audit and harden JWT tokens with security scoring and diff output
Var Name Mangler
Obfuscate variable names in JS, TS, and Python with Devcore mode

FAQ

What is the repairConfidence score?

A 0-1 float that indicates how much the cleaner deviated from the original input. 1.0 means only whitespace or fences were stripped. Below 0.5 means structural repairs (bracket closing, value inference) were applied — the result should be human-reviewed before being trusted in a pipeline.

When should I use aggressive vs conservative repair?

Conservative is the default and only handles cosmetic issues (markdown fences, trailing commas, comments). Aggressive additionally infers missing closing brackets — useful for truncated LLM output but riskier because it guesses structure. Default to conservative; escalate to aggressive only when conservative fails.

How does targetSchema validation work?

Provide a JSON Schema (or Zod-compatible schema) and the cleaner runs validation after repair. Schema errors are returned alongside the cleaned JSON, giving you both the parsed value and a list of fields that violated the contract — without a second tool call.

Can I use this tool via the MCP API?

Yes. The tool is registered on the obfus.link MCP server at https://obfus.link/mcp. Call it from any MCP-compatible agent with a Shared Payment Token. The MCP tool name matches the snake_case slug shown in the integration snippet.