pjson-rs
Parse incomplete JSON while an LLM is still streaming it — 15×–300× faster than pure-Python partial JSON parsers.
When a model streams structured output or tool arguments, standard json.loads() fails until the final } arrives. pjson-rs parses partial JSON safely at any point in the stream, with a drop-in API for partial-json-parser and a streaming parser for long tool calls.
Install
pip install pjson-rs
Prebuilt wheels are included for Linux, macOS, and Windows (Python 3.9+, no Rust toolchain needed).
Usage
Parse incomplete JSON in one line
import pjson_rs
pjson_rs.loads('{"name": "Alice", "tags": ["py')
# {'name': 'Alice', 'tags': ['py']}
# Also accepts bytes / bytearray directly
pjson_rs.loads(b'{"done": tr')
# {'done': True}
Stream chunks as tokens arrive
For long tool calls or high-concurrency servers, StreamParser only scans each new chunk instead of re-parsing the whole string from the start:
import pjson_rs
parser = pjson_rs.StreamParser()
for chunk in ['{"city": "Par', 'is", "temp": 21}']:
parser.feed(chunk)
valid_json = parser.complete() # '{"city": "Par"}' -> '{"city": "Paris", "temp": 21}'
parser.loads() # {'city': 'Paris', 'temp': 21}
parser.done() # True
Drop-in replacement for partial-json-parser (vLLM / SGLang)
import pjson_rs
from pjson_rs import Allow
# Same Allow bitflags as partial-json-parser
pjson_rs.loads('{"msg": "hello', Allow.STR | Allow.OBJ)
# Single-pass raw_decode: handles trailing text and returns exact char offset
text = '{"answer": 42} trailing prose'
obj, end_idx = pjson_rs.raw_decode(text, Allow.ALL)
assert text[end_idx:] == " trailing prose"
Performance
Compared against partial-json-parser on 75%-truncated JSON and 8-byte streaming chunks (benchmarks/bench.py):
| Workload | partial-json-parser |
pjson-rs (x86-64) |
pjson-rs (Apple M4) |
|---|---|---|---|
Single-shot 1 KB |
30.0 µs / 26.5 µs |
2.1 µs (14×) |
1.7 µs (15×) |
Single-shot 8 KB |
200.8 µs / 129.9 µs |
14.5 µs (14×) |
10.9 µs (12×) |
Single-shot 32 KB |
817.2 µs / 605.1 µs |
49.5 µs (17×) |
43.3 µs (14×) |
Streaming 1 KB (8B chunks) |
3.56 ms / 2.16 ms |
0.02 ms (162×) |
0.02 ms (108×) |
Streaming 8 KB (8B chunks) |
130.5 ms / 91.8 ms |
0.39 ms (333×) |
0.31 ms (298×) |
Under the hood
- Written in Rust (PyO3) with zero external runtime dependencies and SIMD string scanning (AVX2 / SSE2 / ARM64 NEON)
- Ships as a compact
cp39-abi3wheel (~270 KB) with PEP 561 type stubs (py.typed+__init__.pyi) - Always raises
json.JSONDecodeErroron invalid syntax and preserves valid UTF-8 across split multi-byte chunks and truncated surrogates
License
MIT
Metadata
Release files for pjson-rs 0.1.1
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 |
|---|---|---|---|---|
| pjson_rs-0.1.1.tar.gz | 22.5 kB | With provenance | Details for pjson_rs-0.1.1.tar.gz |
Built distributions (wheels)
Total release size: 2.1 MB
Release files / pjson_rs-0.1.1.tar.gz
| Download URL | pjson_rs-0.1.1.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b050a04949c50b900fd98d1b37a63c1e63f093a8334754929a0a0e82f0beefed
|
|
BLAKE2b-256 checksum How to use checksums |
73b8564a7cfc535dd7f9ef4c11aee1e187f8efaa9d1482a9d642b664b2be8002
|
| 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 / pjson_rs-0.1.1-cp39-abi3-win_amd64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 174.7 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bca3c3c241d4b376dc04004d54fbc37ea854d63b045f4984781dd1c59b5fe2ca
|
|
BLAKE2b-256 checksum How to use checksums |
e1ea9bd672bec83b3d3cadeec2ac7a8d77dc64233bec40c3e71fd1e3e2b5f935
|
| 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 / pjson_rs-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 397.3 kB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
452d6959575b122cd5aec17d814dc67e9582e992fac3639a7fae94af37699e96
|
|
BLAKE2b-256 checksum How to use checksums |
2c417cb2a74153f5fb7ce2fae39827887504e0e2c25daf3edca1d04432689062
|
| 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 / pjson_rs-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 386.7 kB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ea3deeec920ce229e10837713cf8215d7fef2d0935c7205150c8881b104973fd
|
|
BLAKE2b-256 checksum How to use checksums |
16135bc433a9e09b1ee0b8adaa78e7547a079354051948812241cf250d5367e2
|
| 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 / pjson_rs-0.1.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 292.6 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a97545ce8147b80675600237c5249f9aba4d54e7c569200b820d7567bfae55c9
|
|
BLAKE2b-256 checksum How to use checksums |
ee59e0dcd5569ba643e0bbc9c5d275312c69840a2c0646bdbc6ebaaab1b45ebd
|
| 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 / pjson_rs-0.1.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 292.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ebb08e74762e694095509459df756487a1720d8b422ba938c451bfc75bac0e38
|
|
BLAKE2b-256 checksum How to use checksums |
5b2e2934bd19016f155983cf21001280d4516c966165a6be6dcf7e9c2a3709f3
|
| 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 / pjson_rs-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 264.9 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6fddbedf36fd03269ae6cac7e81c79c9b667b0ea1670788cfd5ddeb6a4900a4e
|
|
BLAKE2b-256 checksum How to use checksums |
9e6f019f715a2f7ee9bc2340b8070af00fbb88cb03e09e8e65eba477beaa8c16
|
| 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 / pjson_rs-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | pjson_rs-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 272.6 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
ba49e8fde0535545c1fd9d92133e07cb436247b2b60052bee8e51c3251d1b8ca
|
|
BLAKE2b-256 checksum How to use checksums |
23de7b4deb961c7ef9654e39dbdc72932d4e8e939c998ed467713bd0b7a450ba
|
| 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 pjson-rs 0.1.1
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 8 files in this release have been uploaded with provenance metadata.
Attestation for pjson_rs-0.1.1.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.