# JsonMend > Repairs broken JSON (typically LLM output) and returns valid JSON plus a list of the fixes applied, with optional JSON Schema validation and type coercion. Public JSON API plus a remote MCP server for AI agents. JsonMend strips Markdown code fences and prose around the JSON, removes comments and trailing commas, converts single and curly quotes, quotes unquoted keys, maps Python `None`/`True`/`False`, inserts missing commas, closes truncated strings, arrays and objects, and wraps NDJSON or several concatenated values into one array. Already-valid JSON is returned unchanged with `"changed": false` and no fixes. Repair uses jsonrepair; schemas are checked with @cfworker/json-schema (drafts 2020-12, 2019-09, 7, 4; only local `$ref`s). Pure computation: JsonMend fetches nothing and does not store your input. ## Quickstart 1. 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,],}"` → `{"ok":true,"json":{"name":"Ada","tags":[1,2]},"fixes":[...]}` 2. Free key (shown once): `curl -X POST 'https://jsonmend.mike-tusa.workers.dev/api/v1/keys' -H 'content-type: application/json' -d '{}'`, then send the same call with `-H 'X-API-Key: jm_...'`. 3. In plain words: without a key, about 10 requests a minute and 30 a day per IP; with a free key, about 30 a minute and 1,000 a month. Inputs up to 102,400 bytes. Every repair or validation (API or MCP `tools/call`) is one request. ## For AI agents - [MCP server](https://jsonmend.mike-tusa.workers.dev/mcp): remote MCP over Streamable HTTP at `https://jsonmend.mike-tusa.workers.dev/mcp` (POST only, stateless, JSON responses, no sessions). Protocol versions: 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 (2026-07-28 per-request `_meta`; older versions use `initialize`). Tools: `repair_json` (`input` required; `format`, `schema`, `coerce`, `draft` optional) and `validate_json` (`schema` required, plus `input` text or `data` value; `coerce`, `draft` optional). Both read-only, no network access. Client config (most MCP clients accept this; some use a different format, for example VS Code uses a `servers` key): `{"mcpServers":{"jsonmend":{"type":"http","url":"https://jsonmend.mike-tusa.workers.dev/mcp"}}}` - [OpenAPI 3.1 spec](https://jsonmend.mike-tusa.workers.dev/openapi.json): machine-readable description of the JSON API - [JSON API docs](https://jsonmend.mike-tusa.workers.dev/docs): human-readable API reference with examples ## JSON API - `POST https://jsonmend.mike-tusa.workers.dev/api/v1/repair` with `{"input":""}` (optional `format`: compact | pretty | preserve; optional `schema`, `coerce`, `draft`), or the raw text as the body with `Content-Type: text/plain`. Returns `json` (the value), `text`, `changed`, `inputWasValid`, `fixes` [{`code`, `message`, `count`}], `warnings`, and `schema` when a schema was sent. Fix codes: `removed_bom`, `stripped_code_fence`, `removed_surrounding_text`, `removed_leading_text`, `removed_trailing_text`, `extra_closing_brackets`, `wrapped_multiple_values`, `comments`, `single_quotes`, `smart_quotes`, `unquoted_keys`, `unquoted_strings`, `trailing_commas`, `extra_commas`, `missing_commas`, `missing_colons`, `python_literals`, `non_json_literals`, `invalid_numbers`, `control_characters`, `truncated`, `other_syntax_fixes`. CORS enabled. - `POST https://jsonmend.mike-tusa.workers.dev/api/v1/validate` with `{"schema":{...},"input":""}` or `{"schema":{...},"data":}` (optional `coerce`, `draft`): `valid`, `errorCount`, `errors` [{`path`, `keyword`, `schemaPath`, `message`}] (at most 50 listed; past 5,000 raw validator errors only the first 5,000 are examined, `errorsTruncated` is true and `errorCount` is a lower bound), `coercions`, `repaired`, `fixes`, `json`. A schema mismatch is HTTP 200 with `"valid": false`. - `POST https://jsonmend.mike-tusa.workers.dev/api/v1/keys` (get a free API key) with `{}` or `{"email":"you@example.com"}` (JSON, no CORS): the key is shown once. - `GET https://jsonmend.mike-tusa.workers.dev/api/v1/usage` (see your key's usage) with your key: this month's usage and quota. - `GET https://jsonmend.mike-tusa.workers.dev/health`: service status and `version` (0.1.3). - Caps: input 102,400 bytes (UTF-8), schema 32,768 bytes, request body 262,144 bytes, nesting depth 256 (for `input` whether or not it needed repair, and for `data`). - Schema complexity: a schema that loops back to itself without descending into the data (e.g. `{"allOf":[{"$ref":"#"},{"$ref":"#"}]}`; the same holds for loops through `not`, `if`/`then`/`else`, `anyOf`/`oneOf` or `dependentSchemas` that point back at an ancestor without going through `properties`/`items` etc.), or applies more than 10,000 subschemas to one value, is rejected up front with 422 `schema_too_complex` (no quota used). Checking data against a schema is limited to 200,000 steps (value × applicable subschema, coercion included; large `enum`/`const` values, each `required`/`dependentRequired` name checked, and each predicted keyword failure (4 steps; `const`/`enum` on objects/arrays are assumed to fail; inside `not` a predicted failure adds 1 step) add steps); over it: 422 `schema_too_complex`, which counts as a request. Other pathological schemas, notably catastrophic regex `pattern`s, can be stopped by the per-request CPU limit instead: the platform then returns a 5xx without the JSON error shape, and the request still counts. - Errors: `{ "ok": false, "error": { "code", "message" } }` with HTTP 400 `invalid_json`/`invalid_arguments`/`invalid_schema`/`empty_input`, 401 `invalid_api_key`, 413 `payload_too_large`/`input_too_large`/`schema_too_large`, 422 `no_json_found`/`unrepairable`/`too_deep`/`schema_too_complex`, 429 `rate_limited`/`ip_daily_quota`/`key_quota_exceeded`/`issuer_quota_exceeded`/`daily_cap_reached` (see `Retry-After`), 503 `not_configured`. ## Limits and keys - Anonymous (no key): about 10 requests per minute and 30 per UTC day per IP (IPv6: per /64, and 90 per /48). - Free API key: about 30 requests per minute and 1,000 per calendar month (UTC); all keys issued to one IP share 3,000 requests per month. Send `X-API-Key: jm_…` or `Authorization: Bearer jm_…`. At most 3 new keys per IP per day. There is no paid plan yet. - The MCP endpoint uses the same keys and the same counters: each `tools/call` is one request. `initialize`, `tools/list` and other non-tool messages don't count toward the request quota, but have a light cap of about 120 per minute per IP (over it: HTTP 429 with `Retry-After`). Over a limit, the tool result has `isError: true` with the reason and `retryAfterSeconds`. An invalid key returns HTTP 401. - What counts: every call that reaches the repair engine or the validator is one request, including failed repairs (422 `unrepairable`, `no_json_found`, `too_deep` found while repairing) and 422 `schema_too_complex` from the step limit. Argument errors (400, 413, and the up-front 422 checks on `data` depth and schema shape) are rejected before any counter and don't count. - MCP request caps: 262,144-byte body, JSON-RPC batches (legacy versions only) of at most 10 messages with at most one `tools/call`. ## Optional - [Homepage and free paste-box tool](https://jsonmend.mike-tusa.workers.dev/) - [Privacy](https://jsonmend.mike-tusa.workers.dev/#privacy) - Contact: digitalpromohub.support@gmail.com