JSON candidate repair

json-candidate-repair · version 1.0.0 · JSON & JSONL · free, no key needed

Conservatively repair a JSON candidate (comments, trailing commas, truncation), log every edit and recheck RFC 8259.

Use when you need to: remove trailing commas from json · strip comments from jsonc before parsing · close truncated json from a cut off llm response.

Decide before calling

Read the versioned contract and the supported scope below. Reuse json-candidate-repair@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use json-candidate-repair@1.0.0 for remove trailing commas from json. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "text": "{\"a\": [1, 2,], // note\n \"b\": tru"
}

Response:

{
  "result": {
    "text": "{\"a\": [1, 2], \n \"b\": tru}",
    "changed": true,
    "valid_json": false,
    "json_error": {
      "code": "invalid_literal",
      "offset": 24
    },
    "edits": [
      {
        "rule": "remove_trailing_commas",
        "offset": 11,
        "removed": ",",
        "inserted": ""
      },
      {
        "rule": "remove_comments",
        "offset": 15,
        "removed": "// note",
        "inserted": ""
      },
      {
        "rule": "close_truncated",
        "offset": 32,
        "removed": "",
        "inserted": "}"
      }
    ]
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "json-candidate-repair",
  "version": "1.0.0",
  "input": {
    "text": "{\"a\": [1, 2,], // note\n \"b\": tru"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/json-candidate-repair/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"{\"a\": [1, 2,], // note\n \"b\": tru"}'

The machine-readable contract is at /v1/tools/json-candidate-repair/versions/1.0.0.

CLI

node cli.mjs run json-candidate-repair 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.