JSON text repair

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

Repair six common lexical JSON defects (comments, trailing commas, single quotes, ...) and list every edit made.

Use when you need to: repair broken json from an llm · fix trailing commas in json · convert single quoted json to valid json.

Decide before calling

Read the versioned contract and the supported scope below. Reuse json-text-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-text-repair@1.0.0 for repair broken json from an llm. 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": "{name: 'Ada', active: True,}"
}

Response:

{
  "result": {
    "repaired": "{\"name\": \"Ada\", \"active\": true}",
    "changed": true,
    "edit_count": 5,
    "edits": [
      {
        "kind": "unquoted_key",
        "start": 1,
        "end": 5,
        "original": "name",
        "replacement": "\"name\"",
        "repaired_start": 1,
        "repaired_end": 7
      },
      {
        "kind": "single_quoted_string",
        "start": 7,
        "end": 12,
        "original": "'Ada'",
        "replacement": "\"Ada\"",
        "repaired_start": 9,
        "repaired_end": 14
      },
      {
        "kind": "unquoted_key",
        "start": 14,
        "end": 20,
        "original": "active",
        "replacement": "\"active\"",
        "repaired_start": 16,
        "repaired_end": 24
      },
      {
        "kind": "python_literal",
        "start": 22,
        "end": 26,
        "original": "True",
        "replacement": "true",
        "repaired_start": 26,
        "repaired_end": 30
      },
      {
        "kind": "trailing_comma",
        "start": 26,
        "end": 27,
        "original": ",",
        "replacement": "",
        "repaired_start": 30,
        "repaired_end": 30
      }
    ]
  }
}

How to call it

MCP

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

{
  "id": "json-text-repair",
  "version": "1.0.0",
  "input": {
    "text": "{name: 'Ada', active: True,}"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/json-text-repair/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"{name: '\''Ada'\'', active: True,}"}'

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

CLI

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

Get the client at /clients/cli/.