Skip to main content

Rust-backed repair of malformed JSON for LLM-style outputs

Project description

repairjson

Blazing-fast JSON repair for messy LLM output.

repairjson is a Rust-powered drop-in repair layer for malformed JSON in Python. It is built for the reality of modern LLM pipelines: broken commas, single quotes, unquoted keys, truncated payloads, Markdown fences, and half-finished responses that still need to get through production systems.

If json.loads() is too strict and Python-side repair is too slow, this is the fast path.

Why repairjson

  • Rust core with a single-pass repair engine
  • designed for malformed LLM-style JSON, not just clean parser input
  • published PyPI wheels
  • benchmarked at roughly ~200x average speedup versus Python json_repair on the current 20 MB malformed corpus suite

What It Repairs

  • single-pass byte-oriented repair
  • support for single-quoted strings
  • support for Python literals like True, False, and None
  • repair of unquoted object keys
  • repair of missing commas and trailing commas
  • auto-closing of truncated objects and arrays
  • stripping of leading and trailing Markdown code fences
  • skipping chatty preambles to recover the first JSON object or array payload

Install

uv add repairjson

For a plain virtual environment:

uv venv
VIRTUAL_ENV=.venv uv pip install --python .venv/bin/python repairjson

Fast Example

uv run --with repairjson python -c "import repairjson; print(repairjson.repair(\"{user: 'alice', active: True, tags: ['x', 'y',],}\"))"

Output:

{"user":"alice","active":true,"tags":["x","y"]}

Usage

import repairjson

fixed = repairjson.repair("{user: 'alice', active: True, tags: ['x', 'y',],}")
print(fixed)
# {"user":"alice","active":true,"tags":["x","y"]}

obj = repairjson.loads("{user: 'alice', active: True, tags: ['x', 'y',],}")
print(obj)
# {'user': 'alice', 'active': True, 'tags': ['x', 'y']}

Performance

Current benchmark suite: six synthetic 20 MB malformed-JSON datasets modeled after LLM-style output patterns.

  • dense_object: 206.2x
  • fenced_payload: 202.81x
  • chatty_nested: 242.24x
  • long_text: 198.91x
  • array_heavy: 209.86x
  • truncated_nested: 229.48x

Average across the current suite: about 214.9x.

The conservative claim is still 100x+, because real-world speedups depend on payload shape, string density, and how broken the JSON is.

The benchmark harness lives in benchmark.py.

Development

Create the local environment and install the package in editable mode:

uv venv
VIRTUAL_ENV=.venv uv pip install --python .venv/bin/python maturin pytest json_repair
uv run maturin develop

Run tests:

cargo test
uv run pytest -q

Run benchmarks:

uv run python benchmark.py --dataset all

Contributing

See CONTRIBUTING.md for the development workflow and pull request expectations.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repairjson-0.1.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (249.3 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (264.2 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

repairjson-0.1.2-cp38-abi3-win_arm64.whl (110.4 kB view details)

Uploaded CPython 3.8+Windows ARM64

repairjson-0.1.2-cp38-abi3-win_amd64.whl (110.3 kB view details)

Uploaded CPython 3.8+Windows x86-64

repairjson-0.1.2-cp38-abi3-win32.whl (105.7 kB view details)

Uploaded CPython 3.8+Windows x86

repairjson-0.1.2-cp38-abi3-musllinux_1_2_x86_64.whl (453.6 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

repairjson-0.1.2-cp38-abi3-musllinux_1_2_i686.whl (485.8 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ i686

repairjson-0.1.2-cp38-abi3-musllinux_1_2_armv7l.whl (527.9 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARMv7l

repairjson-0.1.2-cp38-abi3-musllinux_1_2_aarch64.whl (421.4 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

repairjson-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (251.3 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

repairjson-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (269.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ s390x

repairjson-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (364.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ppc64le

repairjson-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (252.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARMv7l

repairjson-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (245.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

repairjson-0.1.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (265.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.5+ i686

repairjson-0.1.2-cp38-abi3-macosx_11_0_arm64.whl (217.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

repairjson-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl (220.5 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file repairjson-0.1.2.tar.gz.

File metadata

  • Download URL: repairjson-0.1.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for repairjson-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c0f3cb6530112350995e58b7018c1847dcda74a85f595e3c1539246c8b8b3985
MD5 36af0df1d6ff0c5534853a176456073e
BLAKE2b-256 ef5d3f973c487999b0fc93aac5a0a4dfb3a3dea77d9eb7dc0de1870e388b44e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2.tar.gz:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da9308d14c23e6a81cc4c7c8ada54470a7a9b13128740d27de8abec52de6b504
MD5 d3418f66c73d22b6a36f7cf304fe35b9
BLAKE2b-256 53cf32d8b9e3b2cf1ebbab7eb51e32b028b067d23f7f504629049a531eaa8593

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 a76a0ca1092051d1d307395828f8a8a9338d9083da89a564d2ff1c8869df6361
MD5 c62c73ef9b442b42e8e9b03a519af35d
BLAKE2b-256 b3f86a0f46baa41e432ddd0cb95817deab65b902edf07d71a3f3d71ee0b0aa6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-win_arm64.whl.

File metadata

  • Download URL: repairjson-0.1.2-cp38-abi3-win_arm64.whl
  • Upload date:
  • Size: 110.4 kB
  • Tags: CPython 3.8+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 2fe678ca3f4841e986d5a22624bb338ba9ea3257dd04decd08919a7f142eaec9
MD5 bc568316daa13b56bd9433e7fdb65e7f
BLAKE2b-256 dfe9e8f536cdc4e36196bb0e342a0f4097d5d2e15116e2e5528fcfaaf8577f12

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-win_arm64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: repairjson-0.1.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 110.3 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e04bc980aa7801976fc300f555956588c29c1eb62c78a531b13e53a74b67f24d
MD5 d875763320235244c81b6df248f16cb0
BLAKE2b-256 b3d7d6658c32f3a35037f4899ea0ea4878fddcbe1c8874034db9d0b79422279b

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-win_amd64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-win32.whl.

File metadata

  • Download URL: repairjson-0.1.2-cp38-abi3-win32.whl
  • Upload date:
  • Size: 105.7 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 487c7091c89ad9c3b547432a7e92aacd39e12e5d7d026a00c660f066a395975d
MD5 258ea588b09e62cb50a350ce91853070
BLAKE2b-256 8f6ac4b412445c73f520d948dadeaea460ef71532ed6d897ea566f632cbfb0b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-win32.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f206e6e62720c4f5a929c2e788d1b33ba52f36141be5d68dd5f2062f37f9425b
MD5 8d5404619e18429b9a3205d2c0c0aa12
BLAKE2b-256 e5cb3da7911bbbd6fe57b3f9aebea60b2f1ac93f97b97cb0cadaf57bc43c34ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-musllinux_1_2_x86_64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 3166432b674794211e4e7a1585c4dca8e50c003159b46442b34e53f0cb5f082c
MD5 d7aeb4bfecc4ea2a0bca7a0264396ece
BLAKE2b-256 11c87e0fcb02443ea36d43e51d5e469815459f16313c5e1151f086811a9c463f

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-musllinux_1_2_i686.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 9e301ad57b51e88af9ce241277af0a86d8074fecf4457659afbeac4299ef0f99
MD5 5c2ecf725064b0f2fd52264b06f2c6c7
BLAKE2b-256 f5871bfbcf31cc694bd9cfb77ba5049fd878616bf8927b4d312e1335937c40ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-musllinux_1_2_armv7l.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5d85fa5032e38e854b1dd71306e03c75061b18782bd756061dbc2adaa4ea84af
MD5 5ed8757e6797620cdaaaf63fcea1b800
BLAKE2b-256 5e05853101f00826ae33a24af4bc5b5dfea5ca959612776f40ba8badc164243c

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-musllinux_1_2_aarch64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c64c0b9653ee34f6285017b74541a8c3ce2ab5aa7a5a5ae52e62c46a6419a89
MD5 ce563b1b86bda23c4b40b3b6eec1636e
BLAKE2b-256 62ece02ed3d61e2d692167b9541eb5a42aa7317a934f8f33ec555031ba8d7d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 4981c420db5087a62732426f99056befa359a22eca2cc5ad779eb55faac0cf69
MD5 abb2f9315ad9443785ff7b2d39c67ec3
BLAKE2b-256 39d4bceac0b42963c995f958775855080af4525374185effa37509c10cdea887

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 6aa0b8daf5389980ad16c0c63d95b9f497bcbdaf3a3fbef736b1941fb1532d9c
MD5 e4eca7d62caa97325fbe762f3d7bde1e
BLAKE2b-256 d9e3863ddafb61976156939c146c3d767d734a1c43a2153fa597de3c7124a468

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 0db84099a05dcabd1151759ea8aa54f7092d33e9e8ec69ebd6fe8518b381ba1f
MD5 2bcbc63f977f7c734ef0d20bb8ae2e3a
BLAKE2b-256 0dec13428c29ec9b88fd1a389560c6db74ca8623d10d00110f571d09947dee86

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aa2923ab9d055a2de2fbf37dd010ba507c3108fa6189009179607298d1823e00
MD5 cc3c5a3d5ac605e42b99ceaab465571d
BLAKE2b-256 f5df50785f6ba5b62df0664a00266e8e499554de797b12d2e06ed35aa5633d61

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 bfb5e8622b828d35ec0471437adb1881925a092fa240595649d596e842929401
MD5 8ce114e99d2c0e75e85adecdb1551d8d
BLAKE2b-256 098afd83091810f5dc19dbc414ecdc504d49e720e8a2423c6aa2c248f28e53b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f23f099a75152e683d10499dcb79652ee9c28abac51d44ff941d7e02be5c3d64
MD5 be58e3fbd06fad0dc97a05c197355cc7
BLAKE2b-256 e36afbdac1aa4213b4708ffb31abbc2dae6e239f52f33beec537b00cbc1c730d

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repairjson-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for repairjson-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ff5e090b808a5ec85cd95c6d146dab00af5346b546a8cb2b6dc6a2d22ec4c9ef
MD5 e9622a26b941f2f2dfbc31a6dc2c0e29
BLAKE2b-256 76e89077e2221f33bee2ffe7d27624e6c86ab9db7ca86b26f8c862cb940bef62

See more details on using hashes here.

Provenance

The following attestation bundles were made for repairjson-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: CI.yml on kyle-mirich/repairjson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page