Skip to main content

Tidy Byte Tools

json-repair-lite

License: MIT Python 3.10+ MCP server Tests

Free tool that repairs broken or incomplete JSON, including output from language models. Runs offline. No API key.

Need it at scale or from an AI agent? Use the Apify version: json-repair on Apify

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.

  • Apify (no-install cloud version) — pay only for what you use, about $0.001 per document. Empty or unreadable input is free. (This listing goes public this week.)

Before and after

Before (not valid JSON: unquoted keys, single quotes, trailing comma):

{name: 'Ada', ok: true, trailing: 'comma',}

After:

{"name": "Ada", "ok": true, "trailing": "comma"}

Already-valid JSON is left alone and reported honestly as wasValid: true.

Install

pip install git+https://github.com/tidybytetools/json-repair-lite

Or use pipx, which keeps it in its own space:

pipx install git+https://github.com/tidybytetools/json-repair-lite

This 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) json-repair on Apify
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 --from git+https://github.com/tidybytetools/json-repair-lite json-repair-lite mcp

Claude Desktop (claude_desktop_config.json) or Cursor (~/.cursor/mcp.json):

{
  "mcpServers": {
    "json-repair-lite": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/tidybytetools/json-repair-lite", "json-repair-lite", "mcp"]
    }
  }
}

uvx --from git+https://github.com/tidybytetools/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 .json or .jsonl file, 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 --from git+https://github.com/tidybytetools/json-repair-lite json-repair-lite mcp gives two read-only tools, repair_json_text and repair_json_file.
  • Output: with --json, one object: {"ok": true, "count": 1, "failed": 0, "documents": [...]}. On error ok is 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 tests

The 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.

Metadata

Release files for json-repair-lite 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for json-repair-lite 1.0.0
File Size Uploaded Provenance Actions
json_repair_lite-1.0.0.tar.gz 11.2 kB With provenance Details for json_repair_lite-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for json-repair-lite 1.0.0
File Interpreter ABI Platform Actions
json_repair_lite-1.0.0-py3-none-any.whl Python 3 none any Details for json_repair_lite-1.0.0-py3-none-any.whl

Total release size: 20.4 kB

Release files / json_repair_lite-1.0.0.tar.gz

Download URL json_repair_lite-1.0.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ae872ad995de6e95e30795d5d6989de3433ce34069ed8b797f479ce4b43f771c
BLAKE2b-256 checksum
How to use checksums
d8148f43d528d3cfef7c468ade36df89e55e7640314df39a10d272cad6e13b8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / json_repair_lite-1.0.0-py3-none-any.whl

Download URL json_repair_lite-1.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32e710c960c9bda0616c7970dd931ca6b026306e0332fe70fb9c751d66edf724
BLAKE2b-256 checksum
How to use checksums
0c7dc220cfdaf22c6d3fec2483b6edc49b755d3bb6b3d08ee309b352fa6ad5cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for json-repair-lite 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for json_repair_lite-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page