json-repair-lite
json-repair-lite
Free tool that repairs broken or incomplete JSON, including output from language models. Runs offline. No API key.
Example
Input (this is not valid JSON: unquoted keys, single quotes, and a trailing comma):
{name: 'Ada', ok: true, trailing: 'comma',}Output from an actual run of json-repair-lite:
{
"name": "Ada",
"ok": true,
"trailing": "comma"
}Already-valid JSON is left alone and reported honestly as wasValid: true.

Plain code, not AI, so the same input always gives the same output. Runs on your own computer. MIT license. Works with Python 3.10 and newer, on Windows, Mac and Linux.
Also searched as: ES: reparar JSON, JSON roto / PT: reparar JSON / DE: JSON reparieren / FR: réparer un JSON cassé / JA: 壊れたJSONを修復
Related MCP server: streamparse-mcp
Links
Apify (no-install cloud version) — pay $0.001 per document; already-valid JSON is reported honestly
Install
pip install json-repair-liteOr straight from GitHub: pip install git+https://github.com/tidybytetools/json-repair-lite
Or use pipx, which keeps it in its own space:
pipx install json-repair-liteThis also installs the json-repair library, which does the repair work, and the mcp package for the MCP server.
Use it
printf "{name: 'Ada', ok: true,}" | json-repair-lite
json-repair-lite broken.json
json-repair-lite data.jsonl --json-lines
json-repair-lite broken.json --json # {"ok": true, "count": 1, "failed": 0, "documents": [...]}Without --json-lines, the whole text is tried as one JSON value first. If that cannot be repaired and there are several lines, each line is then tried on its own. With --json-lines, each non-empty line is its own document, and each result is printed as one line of JSON.
From Python:
from json_repair_lite import repair_one
repair_one("{name: 'Ada',}")["value"] # {'name': 'Ada'}When you run it in a terminal it prints one short line about the Apify version to stderr after the result. It never goes into your JSON output, it only shows when you are looking at a terminal, and --quiet turns it off.
Known limits
This is a repair step, not a language model. It can close missing brackets and fix common syntax issues. It cannot invent the data you meant to write.
Some text cannot be repaired. Those runs exit with an error.
Local files only. This free tool does not fetch file links from the internet. The Apify version does.
5 MB cap in the MCP file tool. The command line will read a larger local file, but very large jobs are a better fit for Apify.
Lite vs Apify
lite (free, this repo) | ||
Repair broken or incomplete JSON | yes, on your computer | yes, in the cloud |
JSON Lines | yes | yes |
Fetch file links | no | yes |
Many documents in one run | yes, from one file or stdin | yes, including file links |
MCP server for local AI apps | yes | use Apify MCP for the cloud tool |
Price | free | $0.001 per document, including JSON that was already valid. Empty input is free |
Use it from Claude Desktop or Cursor (MCP)
There is a small free MCP server built in. It gives your AI app two tools. Both only read. They never write or change files, and they never use the internet. It needs uv.
Run it by hand to check it starts (it waits quietly for an app to talk to it):
uvx json-repair-lite mcpClaude Desktop (claude_desktop_config.json) or Cursor (~/.cursor/mcp.json):
{
"mcpServers": {
"json-repair-lite": {
"command": "uvx",
"args": ["json-repair-lite", "mcp"]
}
}
}uvx --from json-repair-lite json-repair-lite-mcp starts the same server.
Tools:
repair_json_text(text, json_lines=false): for JSON in the chat.repair_json_file(path, json_lines=false): for a local.jsonor.jsonlfile, up to 5 MB.
For one document, both return {"wasValid", "repaired", "value", "text"}. For several documents, they return {"count", "failed", "documents": [...]}.
For AI agents
Use when: you have JSON that may be missing quotes, have trailing commas, or be cut off, including output from a language model.
Don't use when: you need to fetch a file from a URL, or the file is bigger than 5 MB in MCP. Use the Apify version for those jobs. Do not use it to invent missing data.
Input: text on stdin or a file path. Optional
--json-lines.MCP:
uvx json-repair-lite mcpgives two read-only tools,repair_json_textandrepair_json_file.Output: with
--json, one object:{"ok": true, "count": 1, "failed": 0, "documents": [...]}. On errorokis false. Exit code 0 ok, 1 error.Hint lines go to stderr only, and only in a terminal, so stdout is always clean JSON. See also
llms.txt.
Tests
pip install "mcp>=1.10,<2" "json-repair>=0.64.9,<1"
python3 -m unittest discover testsThe MCP tests are skipped if mcp is not installed.
FAQ
What input does it take? One JSON value, or several JSON Lines. Text on stdin, or a local file.
Do my files leave my computer? No. The tool runs on your computer and never uses the internet.
Do you call an AI model? No. The repair runs offline.
How is this different from the Apify version? The Apify version runs in the cloud, can fetch file links, and is built for many documents in one run. This lite tool is free and local.
Does it work with AI apps? Yes. It includes a free MCP server. No API key.
License
MIT. See LICENSE.
Available Tools
2 toolsrepair_json_fileRepair JSON in a local fileARead-onlyIdempotent
Read a local JSON file and repair it if it is broken or incomplete.
Use this when the JSON is in a file on this computer, so you don't have to paste it. The file is only read, never changed. Files larger than 5 MB are rejected; use the Apify version for bigger jobs. Do not use it for files that are not JSON text.
path: full path to a UTF-8 text file, up to 5 MB. json_lines: if true, each non-empty line is a separate document. If false (default), the whole text is tried as one JSON value first.
Returns the same object as repair_json_text.
Inputs: path (required), json_lines.
repair_json_textRepair broken JSON textARead-onlyIdempotent
Repair broken or incomplete JSON, including output from language models.
Use this when you have JSON in the conversation that may be missing quotes, have trailing commas, or be cut off. It is plain code, not an AI model: it can close missing brackets and fix common syntax issues, but it cannot invent the data you meant to write. Already-valid JSON is returned as-is, with wasValid true and repaired false. Do not use it for a file on disk (use repair_json_file for files).
json_lines: if true, each non-empty line is a separate document. If false (default), the whole text is tried as one JSON value first. If that cannot be repaired and there are several lines, each line is then tried on its own.
For one document, returns {"wasValid", "repaired", "value", "text"}. For several documents, returns {"count", "failed", "documents": [...]}.
Inputs: text (required), json_lines.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools are cleanly separated by input source: repair_json_text handles inline JSON, repair_json_file handles JSON on disk. Each description explicitly tells the agent not to use it for the other case, eliminating any realistic misselection.
Both names follow the same snake_case verb_noun pattern with a shared repair_json_ prefix, and the shared json_lines parameter is named identically across both. Convention is fully predictable.
Two tools is on the thin side, but for a deliberately 'lite' single-purpose server each tool earns its place, covering the only two meaningful input channels (text and file). Nothing extraneous, though the surface is minimal.
Core repair lifecycle is covered: validate, repair, and return both value and text, plus JSON-lines handling and a documented 5 MB ceiling with a pointer to a heavier variant. Minor gap: no write-back of repaired output to a file, so agents must capture the returned text themselves.
Maintenance
Related MCP Connectors
Repair broken LLM JSON and check it against a JSON Schema. Flags cut-off output. Free trial.
Repair broken JSON without changing values, find the exact error, outline or query big payloads.
Remote MCP: JSON repair, JSON Schema validation, JSON to TypeScript, CSV to JSON and JSON to CSV.
Repair malformed JSON from LLM/agent output; optional JSON Schema coercion. Free + x402 paid.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for validating JSON against JSON Schema and repairing malformed/invalid JSON.1MIT
- AlicenseAqualityDmaintenanceMCP server that gives AI assistants the ability to parse partial, messy, or truncated JSON.356 npmMIT
- FlicenseNot gradedqualityDmaintenanceJSON repair & validation MCP server for AI agents: fixes malformed JSON (trailing commas, truncation, etc.) and validates/coerces against a JSON Schema, with deterministic free tier and paid LLM-fallback.1-
- FlicenseNot gradedqualityBmaintenanceEnables MCP-compatible agents and IDEs to deterministically extract JSON and auto-repair malformed schemas, including truncated braces, markdown wrappers, and invalid types, without LLM round-trips.7-