JSON repair map offsets

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

Map code point offsets between JSON text and its lexical repair, flagging offsets that fall inside an edit.

Use when you need to: map json parse error position back to the original text · translate offsets after repairing json · where does this repaired json position come from.

Decide before calling

Read the versioned contract and the supported scope below. Reuse json-repair-map-offsets@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-repair-map-offsets@1.0.0 for map json parse error position back to the original text. 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, /*x*/ b: 2,}",
  "offsets": [
    0,
    1,
    2,
    9,
    13,
    18,
    19
  ],
  "direction": "original_to_repaired"
}

Response:

{
  "result": {
    "direction": "original_to_repaired",
    "original_length": 19,
    "repaired_length": 17,
    "edit_count": 4,
    "mappings": [
      {
        "offset": 0,
        "mapped": 0,
        "exact": true
      },
      {
        "offset": 1,
        "mapped": 1,
        "exact": true
      },
      {
        "offset": 2,
        "mapped": 4,
        "exact": true
      },
      {
        "offset": 9,
        "mapped": 9,
        "exact": false
      },
      {
        "offset": 13,
        "mapped": 10,
        "exact": true
      },
      {
        "offset": 18,
        "mapped": 16,
        "exact": true
      },
      {
        "offset": 19,
        "mapped": 17,
        "exact": true
      }
    ]
  }
}

How to call it

MCP

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

{
  "id": "json-repair-map-offsets",
  "version": "1.0.0",
  "input": {
    "text": "{a: 1, /*x*/ b: 2,}",
    "offsets": [
      0,
      1,
      2,
      9,
      13,
      18,
      19
    ],
    "direction": "original_to_repaired"
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/json-repair-map-offsets/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"{a: 1, /*x*/ b: 2,}","offsets":[0,1,2,9,13,18,19],"direction":"original_to_repaired"}'

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

CLI

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

Get the client at /clients/cli/.