JsonMend API
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
- Without a key you can make about 10 requests a minute and 30 a day from one IP address.
- A free key raises that to about 30 a minute and 1,000 a month.
- Each input can be up to 102,400 bytes, each schema up to 32,768 bytes, nested at most 256 levels deep.
- A repair or a validation counts as one request, whether it comes from the API or an MCP
tools/call.
Endpoints
POST /api/v1/repair: turn broken JSON text into valid JSON and list the fixes.POST /api/v1/validate: check JSON text or a value against a JSON Schema (optionally coercing types).POST /api/v1/keys: get a free API key.GET /api/v1/usage: see this month's usage for your key.POST /mcp: the same two tools for AI agents over MCP.GET /health: service status and version.
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:
removed_bom: Removed a byte-order mark (BOM) at the startstripped_code_fence: Removed a Markdown code fence (```json … ```)removed_surrounding_text: Removed text outside the code fenceremoved_leading_text: Removed text before the JSONremoved_trailing_text: Removed text after the JSONextra_closing_brackets: Removed extra closing brackets after the JSONwrapped_multiple_values: Wrapped several top-level JSON values (NDJSON / concatenated output) in one arraycomments: Removed comments (// … or /* … */)single_quotes: Converted single-quoted strings to double quotessmart_quotes: Converted curly “smart” quotes to straight double quotesunquoted_keys: Quoted unquoted object keysunquoted_strings: Quoted bare-word string valuestrailing_commas: Removed trailing commasextra_commas: Removed extra (leading or doubled) commasmissing_commas: Inserted missing commasmissing_colons: Inserted missing colons between keys and valuespython_literals: Converted Python None/True/False to null/true/falsenon_json_literals: Replaced non-JSON literals (undefined → null; NaN/Infinity → strings)invalid_numbers: Fixed non-JSON number syntax (e.g. .5, hex, leading +)control_characters: Escaped raw control characters (newlines, tabs) inside stringstruncated: Input was cut off: closed the unfinished string/brackets (values at the cut may be incomplete)other_syntax_fixes: Fixed other syntax errors
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