{"@context":"https://obfus.link/schema/tool/v1","tool":{"name":"LLM to JSON Cleaner","slug":"llm-to-json-cleaner","mcpToolName":"llm_to_json_cleaner","tier":"tier_3","tierLabel":"Tier 3 — Premium","category":"converters","canonicalUrl":"https://obfus.link/tool/llm-to-json-cleaner","endpoint":"https://obfus.link/mcp","priceMicros":25000,"tagline":"Repair malformed JSON from LLM responses with confidence scoring","atomicAnswer":"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.","description":"Strips markdown fences, comments, and trailing commas. Closes unclosed brackets in aggressive mode. Validates against an optional JSON Schema and returns a 0-1 repair confidence score so agents can decide whether to auto-accept or escalate.","inputSchema":{"type":"object","required":["raw"],"properties":{"raw":{"type":"string","description":"Raw LLM output containing JSON"},"strict":{"type":"boolean"},"targetSchema":{"type":"object"},"repairStrategy":{"enum":["conservative","aggressive"],"type":"string"}}},"outputSchema":{"type":"object","properties":{"json":{"type":["object","array","null"]},"cleaned":{"type":"string"},"schemaErrors":{"type":"array"},"transformations":{"type":"array"},"repairConfidence":{"type":"number"}}},"agenticReasoning":"USE THIS WHEN: (1) An LLM tool call returned JSON wrapped in a markdown code fence and you need the parsed structure. (2) The JSON contains trailing commas, single quotes, or comments that prevent JSON.parse() from succeeding. (3) The LLM response was truncated mid-output and is missing closing brackets — use aggressive mode to infer the structure. (4) You need to repair AND validate the output against a schema in a single call without round-tripping through a separate validator. DO NOT USE WHEN: the input is already valid JSON — call JSON.parse() directly and skip the cost. Do not use when the input is XML, YAML, or another structured format. OVER ALTERNATIVES: prefer this over manual regex repair (misses string-aware stripping and produces malformed output when commas appear inside string literals) and JSON5 parsers (no repairConfidence score, no schema validation, no aggressive bracket recovery).","mcpDescription":"Repairs malformed JSON in LLM tool-call output. USE WHEN: an LLM returned JSON in a markdown fence, the JSON has trailing commas or comments preventing JSON.parse, the response was truncated mid-output, or you need to clean AND validate against a schema in one call. INPUT: raw string, optional schema, strategy. OUTPUT: parsed JSON, cleaned string, transformations applied, schema errors, confidence score. COST: 1 unit.","howTo":[{"step":"Paste raw LLM output","description":"Drop in the unparsed string with markdown fences, comments, or trailing commas."},{"step":"Choose repair strategy","description":"Conservative strips fences and commas. Aggressive also infers missing closing brackets."},{"step":"Add a target schema (optional)","description":"Provide a JSON Schema object for one-call validation alongside repair."},{"step":"Check repair confidence","description":"A score of 1.0 means only whitespace was changed. Below 0.5 means structural repairs occurred."},{"step":"Inspect transformations","description":"Each repair is logged with type, description, and position so you can audit the changes."}],"faqs":[{"question":"What is the repairConfidence score?","answer":"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."},{"question":"When should I use aggressive vs conservative repair?","answer":"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."},{"question":"How does targetSchema validation work?","answer":"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."},{"question":"Can I use this tool via the MCP API?","answer":"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."}],"workflowChains":{"live":[],"planned":[]},"tags":["json","llm","repair","clean","parse","validate","markdown"],"tddVerified":true,"mcpCostUnits":1}}