JsonMend API

← paste-box tool

Quickstart

1. Try it with no key:

curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/repair' -H 'content-type: text/plain' \
  --data-binary "{name: 'Ada', tags: [1,2,],}"

2. Get a free key (shown once), then send the same call with it:

curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/keys' -H 'content-type: application/json' -d '{}'
curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/repair' -H 'content-type: text/plain' -H 'X-API-Key: jm_...' \
  --data-binary "{name: 'Ada', tags: [1,2,],}"

Limits in plain words

Endpoints

POST /api/v1/repair

curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/repair' -H 'content-type: application/json' \
  -d '{"input":"```json\n{\"a\": 1, \"b\": [1,2,],}\n```","format":"compact"}'
curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/repair?format=pretty' -H 'content-type: text/plain' --data-binary @llm-output.txt

Body fields: input (string, required, max 102,400 bytes), format (compact default, pretty, preserve = keep the repaired text's spacing and long-number digits), optional schema, coerce, draft (validate the result too). Or send the raw text as the body with Content-Type: text/plain.

{
  "ok": true, "changed": true, "inputWasValid": false, "values": 1,
  "fixes": [ { "code": "stripped_code_fence", "message": "..." }, { "code": "trailing_commas", "message": "...", "count": 2 } ],
  "warnings": [],
  "json": { "a": 1, "b": [1, 2] },
  "text": "{\"a\":1,\"b\":[1,2]}",
  "format": "compact", "inputBytes": 37, "outputBytes": 17
}

Already-valid JSON comes back unchanged with "changed": false and no fixes. Several top-level values (NDJSON, or objects one after another) are wrapped in one array (wrapped_multiple_values). If nothing JSON-like can be recovered the answer is 422 with no_json_found or unrepairable (plus position when known).

Fix codes:

POST /api/v1/validate

curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/validate' -H 'content-type: application/json' \
  -d '{"schema":{"type":"object","required":["age"],"properties":{"age":{"type":"integer"}}},"input":"{age: \"42\"}","coerce":true}'

Send schema plus either input (JSON text, repaired first if broken) or data (an already-parsed value). coerce: true converts values toward the schema's types ("42" → 42, "true" → true, "null" → null, 5 → "5", x → [x]) and lists every change in coercions. Drafts 2020-12 (default), 2019-09, 7 and 4; the draft is taken from $schema when present. Only local $refs (#/...) resolve; JsonMend never fetches remote schemas. A mismatch is a normal 200 with "valid": false and up to 50 errors (path is a JSON Pointer).

{ "ok": true, "valid": true, "errorCount": 0, "errors": [], "draft": "2020-12",
  "coerced": true, "coercions": [ { "path": "/age", "from": "string", "to": "integer" } ],
  "repaired": true, "fixes": [ { "code": "unquoted_keys", "message": "..." } ], "warnings": [], "json": { "age": 42 } }

Limits & free API keys

Anonymous: 10 requests/minute and 30/day per IP (IPv6: per /64; 90/day per /48). With a free key (X-API-Key or Authorization: Bearer): 30/minute and 1,000/month (UTC calendar month). All keys issued to one IP share 3,000 requests/month.

curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/keys' -H 'content-type: application/json' -d '{"email":"you@example.com"}'
curl -H 'X-API-Key: jm_...' 'https://jsonmend.mike-tusa.workers.dev/api/v1/usage'

email is optional contact info and is not verified. At most 3 keys per IP per day.

Errors: { "ok": false, "error": { "code", "message" } }. 400 invalid body/arguments/schema, 401 bad key, 405 wrong method, 413 body/input/schema too large, 415 keys endpoint needs JSON, 422 no JSON found / unrepairable / too deeply nested, 429 rate limit or quota (see Retry-After), 503 not configured.

MCP server for AI agents

POST https://jsonmend.mike-tusa.workers.dev/mcp: remote MCP (Streamable HTTP, stateless, JSON responses). Tools repair_json and validate_json (read-only, no network access). Same keys and limits as the JSON API; each tools/call is one request. Machine-readable: /llms.txt, /openapi.json.

Other

GET /health: service status. /sitemap.xml, /robots.txt. Contact: digitalpromohub.support@gmail.com