json-stream
Streaming JSON encoder and decoder
What it is and what it does
json-stream is a JSON parser and encoder that processes data incrementally rather than loading entire documents into memory. It provides two primary modes: transient mode for minimal memory footprint (data is discarded after reading), and persistent mode for full random access like the standard library's json module. The package supports streaming from files, URLs, and iterators, and can handle multiple JSON documents in a single stream or JSON mixed with other data.
The package includes a visitor-based interface for depth-first traversal, native code parsing speedups for common platforms via json-stream-rs-tokenizer, and a pure Python fallback. It is designed to reduce memory consumption and latency when processing large or continuously arriving JSON data, making it suitable for applications that cannot afford to buffer entire documents.
Use it for:
- Process large JSON files that exceed available memory by streaming them incrementally.
- Parse NDJSON (newline-delimited JSON) or JSON Lines formats from log files or APIs.
- Consume JSON data from HTTP responses without buffering the entire response body.
- Implement visitor-pattern callbacks to extract specific fields from deeply nested JSON structures.
- Mix transient and persistent parsing modes to balance memory usage and random access within a single document.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Streams JSON data from files, URLs, or iterators without loading the entire document into memory, offering both dict/list-like and visitor-based interfaces for parsing and encoding.
Yes. The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real problem (memory-efficient JSON streaming) that the standard library does not address. It is production-stable and supports current Python versions. Install it if you regularly work with large JSON files, streaming APIs, or NDJSON formats.
Install
json-stream on PyPI
pip
pip install json-streamuv
uv add json-streampoetry
poetry add json-streamInstalling json-stream
Before you install
Low friction install with a single native runtime dependency (json-stream-rs-tokenizer). Actively maintained with recent commits and stable production status across Python 3.8–3.14.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects.
Quickstart
import json_stream
# Transient mode (low memory):
with open('large.json') as f:
data = json_stream.load(f)
for item in data['results']:
print(item)
# Persistent mode (full access):
with open('data.json') as f:
data = json_stream.load(f, persistent=True)
print(data['key']) # random access
Verify before relying
- Performance comparison to standard json.load() on typical file sizes and network streams.
- Behavior and error recovery when encountering truncated or malformed JSON mid-stream.
- Memory overhead of the json-stream-rs-tokenizer native extension vs. pure Python fallback.
Package facts
| License | Copyright (c) 2020 Jamie Cockburn Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (<4,>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — json-stream-rs-tokenizer |
| Maintenance | actively maintained — 109 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,233,796/month — #4,180 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_stream-2.5.1-py3-none-any.whl
Keywords: json, stream, decoder, encoder, parsing
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
json-stream-rs-tokenizerA Rust-based JSON tokenizer that accelerates…
unclear · top 5,000 on PyPI
jsonlinesSimplifies reading and writing jsonlines…
permissive · top 5,000 on PyPI
ndjsonProvides a familiar JSON Lines (ndjson) parser…
copyleft · top 5,000 on PyPI
jsonstreamsWrites JSON documents in a streaming format…
permissive · top 15,000 on PyPI
visitorProvides a base Visitor class to implement the…
permissive · top 15,000 on PyPI
nominal-streamingStreams time-series data to Nominal Core with…
permissive · top 15,000 on PyPI
base64ioProvides a streaming interface for Base64…
permissive · top 15,000 on PyPI
crickCrick provides approximate and streaming…
permissive · top 15,000 on PyPI
jqPython bindings for jq 1.8.2 that let you…
permissive · top 5,000 on PyPI
streamingjsonCompletes partial JSON strings into…
permissive · top 15,000 on PyPI