skillfed

json-stream

Streaming JSON encoder and decoder

json-stream v2.5.1 1.2M downloads/30d#4,180 on PyPI190
Permissive 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) Active released

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-stream

uv

uv add json-stream

poetry

poetry add json-stream

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries

Tags

streaming json parsermemory-efficient json parsingjson decoder iteratorlarge json file processingjson streaming encoderincremental json parsingjson visitor pattern
streaming-iojson-parsingmemory-efficient

More Libraries packages