Skip to main content

blitzjson

License: MIT

Drop-in replacement for Python's json module with native Django type support. Built with Rust via PyO3 for maximum performance.

Features

  • Drop-in replacement: Same API as json.dumps(), json.loads(), etc.
  • Native Django types: Handles datetime, date, time, timedelta, UUID, Decimal, QuerySet, Model, Promise without custom encoders
  • Rust-powered: Direct serialization to JSON buffer via CPython FFI, no intermediate Python objects
  • Zero dependencies: No runtime Python dependencies required
  • Full json API: ensure_ascii, indent, sort_keys, allow_nan, default (recursive)
  • Streaming: stream_dump_queryset() for memory-efficient large QuerySet serialization
  • Django integration: BlitzJsonResponse, BlitzJSONEncoder, install() monkey-patch

Installation

pip install blitzjson

Quick Start

# Before
import json
from datetime import datetime

json.dumps({"created": datetime.now()})  # TypeError!

# After
import blitzjson as json

json.dumps({"created": datetime.now()})  # Works!

Monkey-patching (try before you commit)

If you want to test blitzjson in your existing project without changing any import json statements, use the install() function to monkey-patch Python's built-in json module:

# In your settings.py or at the top of manage.py
import blitzjson
blitzjson.install()

# Now ALL code that uses `import json` will use blitzjson instead
import json
json.dumps({"created": datetime.now()})  # Works! No TypeError!

Or test it interactively:

>>> import blitzjson
>>> blitzjson.install()
>>> import json
>>> json.dumps({"created": datetime.now(), "uuid": uuid4()})
'{"created": "2024-01-15T10:30:45+00:00", "uuid": "550e8400-e29b-41d4-a716-446655440000"}'

>>> # Revert when done testing
>>> blitzjson.uninstall()

Supported Types

Python Type JSON Output Example
datetime ISO 8601 string "2024-01-15T10:30:45Z"
date ISO date string "2024-01-15"
time ISO time string "10:30:45"
timedelta ISO 8601 duration "P1DT2H3M4S"
UUID Hyphenated string "550e8400-e29b-41d4-a716-446655440000"
Decimal String (precision-safe) "123.456789012345678901"
bytes Base64 string "aGVsbG8="
set/frozenset Array [1, 2, 3]
enum Value "value"
dataclass Object {"field": "value"}

Django-Specific

Django Type JSON Output
QuerySet Array of model dicts
Model Dict of field values
Promise (lazy strings) String

API

dumps(obj, **kwargs)

import blitzjson as json

# Standard usage
json.dumps({"key": "value"})

# With Django types
json.dumps({"created": datetime.now(), "uuid": uuid4()})

loads(s, **kwargs)

obj = json.loads('{"key": "value"}')

# With object_hook
obj = json.loads('{"key": "value"}', object_hook=lambda d: {k.upper(): v for k, v in d.items()})

dump(obj, fp, **kwargs) / load(fp, **kwargs)

File-based serialization/deserialization.

dumpb(obj, pretty=False)

Serialize to bytes (faster than dumps for network responses).

dump_queryset(queryset) / dump_queryset_bytes(queryset)

Optimized serialization for Django QuerySets.

Benchmarks

vs json + DjangoJSONEncoder (CPython 3.14, Linux x86_64, consumer hardware):

Note: Benchmarks run on consumer hardware (AMD Ryzen 9 7900X). CI runners (Intel Xeon server CPUs) may show different results due to lower single-thread performance. For stable benchmarks, run locally with uv run python benchmarks/bench_serialization.py.

dumps

Benchmark                           json+DJE    blitzjson    Speedup
------------------------------------------------------------------------
Simple dict (4 fields)                 2.5µs        0.8µs      3.0x
Nested dict (deep)                     5.4µs        1.8µs      3.0x
Large list (1000 items)              752.1µs      193.2µs      3.9x
String-heavy dict (20 keys)            4.8µs        1.5µs      3.1x
Datetime dict                         10.3µs        3.6µs      2.8x
UUID dict                              7.3µs        3.9µs      1.9x
Decimal dict                           4.4µs        1.6µs      2.7x
Mixed dict (all types)                 7.3µs        2.8µs      2.6x

loads

Benchmark                               json    blitzjson    Speedup
------------------------------------------------------------------------
Simple dict (4 fields)                 1.5µs        0.8µs      2.0x
Nested dict (deep)                     5.1µs        3.2µs      1.6x
Large list (1000 items)              716.0µs      421.2µs      1.7x
String-heavy dict (20 keys)            4.3µs        2.7µs      1.6x

Django Response

Benchmark                             JsonResponse      BlitzJson    Speedup
------------------------------------------------------------------------
API response (50 users)                 44.9µs         19.6µs      2.3x

Requirements

  • Python 3.10+
  • No Rust installation required (pre-built wheels)

License

MIT - Ricardo Robles Fernández

Metadata

Release files for blitzjson 0.1.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 blitzjson 0.1.0
File Size Uploaded Provenance Actions
blitzjson-0.1.0.tar.gz 39.7 kB With provenance Details for blitzjson-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for blitzjson 0.1.0
File Interpreter ABI Platform Actions
blitzjson-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for blitzjson-0.1.0-cp310-abi3-win_amd64.whl
blitzjson-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for blitzjson-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
blitzjson-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for blitzjson-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 768.1 kB

Release files / blitzjson-0.1.0.tar.gz

Download URL blitzjson-0.1.0.tar.gz
Size 39.7 kB
Tags Source
SHA-256 checksum
How to use checksums
593997d806ad39ca5e36ea4415df850b12743ab05a437f9975ea4b336d5d6964
BLAKE2b-256 checksum
How to use checksums
eebf3cd7b70d8c1c55cbb8d5c208ed29f45763b99b9caa2c4377b8264e8e271f
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 Aug 25, 2026.

Transparency log

Release files / blitzjson-0.1.0-cp310-abi3-win_amd64.whl

Download URL blitzjson-0.1.0-cp310-abi3-win_amd64.whl
Size 190.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5af218fadc4385ae5ec8eb20e63eeb320f51cccc85799d75e3140033931cfbb0
BLAKE2b-256 checksum
How to use checksums
712389ac67ed3686c0343cce83df440ee8baefc200749363cb37f3880d368a5a
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 Aug 25, 2026.

Transparency log

Release files / blitzjson-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL blitzjson-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 277.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
ff8a43694a406694c6dcf8ac943dbfd8aedc95fb76f1154529c21c205f10e418
BLAKE2b-256 checksum
How to use checksums
67fc5c6094c6c97eb09bb20858fda7a16a3492ed79aaddfacc86fba58f864d82
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 Aug 25, 2026.

Transparency log

Release files / blitzjson-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL blitzjson-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 259.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aa3b3d766905987f55c073d68b4ade59ea55b85d2a0f72880262c5727d704972
BLAKE2b-256 checksum
How to use checksums
23eeb97d3014a335cd6ac9b0d04f031ae7ba8df886e1de6125092b67256f4ec6
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 Aug 25, 2026.

Transparency log

Security for blitzjson 0.1.0

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 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for blitzjson-0.1.0.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 Aug 25, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

4 release files Full provenance

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