Repair broken or LLM-generated JSON
mend_repair_jsonRead-onlyIdempotent
Use when JSON from an LLM, API, log, config or copy-paste fails to parse (JSON.parse error, "Unexpected token", "Expecting property name"), or the user pastes JSON with trailing commas, single quotes, unquoted keys, comments, Python True/False/None, NaN, missing commas or brackets, a ```json fence, text around it, or output that was cut off. Deterministic repair: returns valid, formatted JSON plus a list of every fix with line and column. Values are never rewritten, so big numbers, number formatting and key order stay exactly as written. If the text is already valid it says so. Up to 100,000 characters.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The broken JSON, or any text that contains JSON (a chat reply, a log line, a code block). | |
| indent | No | Spaces per indent level in the output. Default 2. Use 0 for one minified line. | |
| sort_keys | No | Sort object keys alphabetically. Default false (keep the original order). |