Repair malformed JSON from a model
fix_jsonRepair malformed JSON from LLMs by removing code fences, prose, trailing commas, smart quotes, single quotes, and unquoted keys. Returns clean parsed JSON with repairs or closest error.
Instructions
Best-effort repair of broken JSON (code fences, trailing commas, smart quotes, unquoted keys, single quotes, prose around the object, bare words). Returns the parsed value as clean JSON plus a list of the repairs applied — or, if unrepairable, the error and the closest candidate. Call this before re-asking the model.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"text": "<text>"
},
"name": "fix_json"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | the raw broken JSON text |