jsonheal
Repair the broken JSON that language models return. Pure Python, no dependencies.
Fixes: markdown code fences and chatter around the JSON, trailing commas, single quotes, unquoted keys, None/True/False, comments, smart quotes, and output that was cut off mid-way (open strings, arrays and objects get closed).
from jsonheal import heal
heal("Sure! ```json\n{'name': 'Ali', tags: ['a', 'b',],}\n```")
# {'name': 'Ali', 'tags': ['a', 'b']}
heal('{"items": [{"id": 1}, {"id": 2')
# {'items': [{'id': 1}, {'id': 2}]}
CLI:
cat llm_output.txt | python -m jsonheal
Valid JSON is returned untouched. If nothing sensible can be recovered it raises ValueError. Truncated output is repaired structurally, so check that the data you get back is complete enough for your use.
Install
pip install jsonheal
Or copy jsonheal.py into your project, it has no dependencies.
Test
python -m pytest
MIT licensed.
Metadata
Release files for jsonheal 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsonheal-0.1.0.tar.gz | 4.1 kB | With provenance | Details for jsonheal-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonheal-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for jsonheal-0.1.0-py3-none-any.whl |
Total release size: 8.6 kB
Release files / jsonheal-0.1.0.tar.gz
| Download URL | jsonheal-0.1.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df77f6c20110b6f391c58bf9c101900abb175c1faece5f046f5c7ff6a6480007
|
|
BLAKE2b-256 checksum How to use checksums |
05da3da683493ec41b385921dc122099ec2a8b05b167df4fcef9f2f1a779807e
|
| 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 28, 2026.
Transparency logRelease files / jsonheal-0.1.0-py3-none-any.whl
| Download URL | jsonheal-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a36f1d1aa8f005df04d1ae9111b61fb98fc47844d2d84f468c3c1ff61a5ec3c9
|
|
BLAKE2b-256 checksum How to use checksums |
a44186f1f599b488ab1408151ad5261fc37f07900dd6683ac5c746f5065104fa
|
| 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 28, 2026.
Transparency logSecurity for jsonheal 0.1.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.
Attestation for jsonheal-0.1.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 28, 2026.
Transparency logA 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.