Skip to main content

json-healer-lite

PyPI version Python versions License: MIT

A zero-dependency Python micro-tool to instantly repair and parse malformed, truncated, or markdown-wrapped JSON strings generated by LLMs.

The Problem

When using Large Language Models (LLMs) to generate JSON, you frequently encounter three issues that crash json.loads():

  1. Markdown Wrappers: The LLM wraps the output in ```json ... ```.
  2. Token Limits / Streaming: The response is cut off mid-generation, leaving unclosed brackets [{ or unclosed strings.
  3. Trailing Commas: The LLM leaves a trailing comma like {"a": 1, }.

The Solution

json-healer-lite is a pure standard library tool that acts as a robust middle layer. It cleans the string, balances the stack of missing brackets, and safely parses the JSON—saving your API pipelines from crashing.

Installation

pip install json-healer-lite

Usage

from json_healer_lite import heal_json, JSONHealerError
# Typical LLM output that got cut off due to max_tokens:
broken_llm_output = """
{
  "status": "success",
  "data": [
    {"name": "Alice", "score": 95},
    {"name": "Bob", "score": 82,
"""
try:
    # Heals markdown, trailing commas, and auto-closes the string, dict, and array!
    healed_data = heal_json(broken_llm_output)
    
    print(healed_data)
    # Output: {'status': 'success', 'data': [{'name': 'Alice', 'score': 95}, {'name': 'Bob', 'score': 82}]}

except JSONHealerError as e:
    print(f"JSON was too corrupted to save: {e}")

Why zero-dependency

Frameworks like LangChain provide output parsers, but pulling in a massive dependency tree just to fix a few missing brackets adds latency and bloat (especially in serverless environments like AWS Lambda). This micro-tool operates in under 1ms and weighs just a few kilobytes.

Metadata

Release files for json-healer-lite 0.1.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-healer-lite 0.1.0
File Size Uploaded Provenance Actions
json_healer_lite-0.1.0.tar.gz 4.9 kB With provenance Details for json_healer_lite-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 9.3 kB

Release files / json_healer_lite-0.1.0.tar.gz

Download URL json_healer_lite-0.1.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bf28f3cbe6bb0b55a014789c0c573031a6373c75009dbad83037fab90335f649
BLAKE2b-256 checksum
How to use checksums
7861cad2b6c929096b0782dc459af519ea87bc9b6905c6f90709d4814e6dfa89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 2, 2026.

Transparency log

Release files / json_healer_lite-0.1.0-py3-none-any.whl

Download URL json_healer_lite-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00fcb7463f6ad7d77e7b6a052ad791b3a39303d1dc487bab2e41db00b82e6c21
BLAKE2b-256 checksum
How to use checksums
67c07124b009241ddb871cbe5224daeffca8b694732ece50edade2e330495150
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 2, 2026.

Transparency log

Security for json-healer-lite 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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for json_healer_lite-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 Sep 2, 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

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