Skip to main content

Streaming JSON Parser

High-performance JSON decoding and true incremental parsing for Python streams. The package chooses an appropriate backend for complete documents, NDJSON, typed decoding, selective extraction, and partial input. The strict incremental API owns the semantics that ordinary JSON decoders do not provide.

The current release is 0.2.0 and is in beta while the public API settles.

Install

python -m pip install streaming-json-parser

Optional backend groups:

python -m pip install 'streaming-json-parser[accelerated]'
python -m pip install 'streaming-json-parser[partial]'

The Rust extension is optional. When a compatible wheel is available, install it separately:

python -m pip install streaming-json-parser-native

The Python implementation remains functional without optional dependencies.

Choose An API

Workload API
Complete JSON document decode_complete_json
Complete document with zero-copy view semantics decode_complete_json_view
Newline-delimited JSON decode_ndjson or StreamingJsonParser(framing="ndjson")
True incremental parsing StreamingJsonParser
Structural partial snapshots decode_structural_partial_json
Repeated selective extraction make_tuned_json_path_extractor

There is no universal fastest decoder for every payload. The tuned factories calibrate compatible backends for a representative workload; the benchmark scorecard records the current evidence.

Complete Documents

from streaming_json_parser import decode_complete_json

value = decode_complete_json(b'{"name":"example","ok":true}')
assert value == {"name": "example", "ok": True}

For a stable repeated workload, bind a decoder once:

from streaming_json_parser import make_tuned_complete_json_decoder

decode = make_tuned_complete_json_decoder(
    sample=b'{"id":1,"name":"example"}',
    payload_size_hint=1024,
)
value = decode(b'{"id":2,"name":"another"}')

Incremental Streams

StreamingJsonParser preserves state across chunks and reports one of EMPTY, PARTIAL, COMPLETE, or INVALID.

from streaming_json_parser import StreamingJsonParser, ParseStatus

parser = StreamingJsonParser()
result = parser.feed(b'{"message":"hel')
assert result.status is ParseStatus.PARTIAL
assert result.value == {"message": "hel"}

result = parser.feed(b'lo"}')
assert result.status is ParseStatus.COMPLETE
assert result.value == {"message": "hello"}

Call finish() when the input source ends. This is required for ambiguous root scalars and for an NDJSON stream whose final record has no trailing newline.

parser = StreamingJsonParser()
parser.consume("12")
result = parser.finish()
assert result.value == 12

For NDJSON, use poll_many() to drain complete records:

parser = StreamingJsonParser(framing="ndjson")
parser.consume(b'{"id":1}\n{"id":2}\n')
assert parser.poll_many() == [{"id": 1}, {"id": 2}]

Partial JSON

Structural mode is useful when an unfinished string value does not need to be returned. It is a cumulative finisher, not a resumable strict state machine:

from streaming_json_parser import decode_structural_partial_json

assert decode_structural_partial_json('{"items":[1,2') == {"items": [1, 2]}
assert decode_structural_partial_json('{"text":"hel') == {}
assert decode_structural_partial_json('{"text":"hel', trailing_strings=True) == {
    "text": "hel"
}

Use StreamingJsonParser(partial_mode="structural") when the prefix arrives as many small chunks and a stateful parser is preferable.

Selective Extraction

from streaming_json_parser import make_tuned_json_path_extractor

extract = make_tuned_json_path_extractor(
    ("meta", "name"),
    ("meta", "count"),
    framing="single",
    sample={"meta": {"name": "example", "count": 1}},
    payload_size_hint=1024,
)
assert extract(b'{"meta":{"name":"example","count":2}}') == ("example", 2)

Development

python -m pip install -e '.[test]'
pytest

Build and inspect release artifacts locally:

python -m build
python -m twine check dist/*

Benchmark artifacts are optional and can be regenerated with:

make benchmark-artifacts
make verify-benchmark-artifacts

The package supports Python 3.10 and later. It is distributed under the MIT license.

Release files for streaming-json-parser 0.2.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 streaming-json-parser 0.2.0
File Size Uploaded
streaming_json_parser-0.2.0.tar.gz 50.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streaming-json-parser 0.2.0
File Interpreter ABI Platform
streaming_json_parser-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 79.3 kB

Release files / streaming_json_parser-0.2.0.tar.gz

Download URL streaming_json_parser-0.2.0.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f034eb27c20176ed3877cdf7b8139680c0ed498bd364de1ad2d2cb3d790b7aeb
BLAKE2b-256 checksum
How to use checksums
e6ccae3ce32ab10260e87e10f80ed3de8291535e6b2a7505ea32a0b8a6abe818
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 23, 2026.

Transparency log

Release files / streaming_json_parser-0.2.0-py3-none-any.whl

Download URL streaming_json_parser-0.2.0-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84c2abb2d2c49f56f799b42f3c1877f384bdc013cc2b9a99ee987cbc0eaf021e
BLAKE2b-256 checksum
How to use checksums
0557469de7becee6415cb2fb054c2cff7de1feae0301b85ed736ae55600a9ec0
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 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.2

2 release files

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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