orjson

A fast, correct, Rust-backed JSON library for Python with native dataclass, datetime, and numpy support

Library
PyPI
v3.12.0
8,234 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
68 /100 Good
Development Activity 56
Maintenance 64
Community 52
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 85
Code Quality 82
Innovation 80
Learning Curve 78

orjson is a fast, correct JSON library for Python, implemented in Rust and exposed via PyO3 bindings. It benchmarks as the fastest Python JSON library and serializes dataclass, datetime, numpy, and UUID instances natively, without needing a custom default handler for the common cases most projects hit.

orjson.dumps() is roughly 10x faster than the standard library’s json module and orjson.loads() roughly 2x faster, while staying strictly compliant with UTF-8 and RFC 8259. It intentionally does not provide file I/O or line-delimited JSON helpers, keeping its scope to serialization/deserialization only, and treats adding an implicit serialization for a new type without an opt-in flag as a breaking change under its semver policy.

What You Get

  • A dumps/loads API that is a near drop-in replacement for the standard library json module
  • Native serialization of dataclasses, datetime/date/time objects, numpy arrays, and UUIDs without a custom default function
  • Strict RFC 8259 and UTF-8 compliant deserialization, more correct than json or most third-party alternatives
  • Prebuilt wheels for amd64/arm64/ppc64le/s390x across Linux, macOS, and Windows, with AVX-512 runtime acceleration when available
  • A stable semver policy where any new implicit type serialization is treated as a breaking change

Common Use Cases

  • Speeding up API response serialization in high-throughput Python web services
  • Serializing dataclass-based domain models directly to JSON without writing custom encoders
  • Working with numpy-heavy data pipelines that need fast JSON I/O for arrays
  • Replacing json.dumps/json.loads calls in performance-sensitive code paths with minimal migration effort

Under The Hood

Architecture - orjson is a thin Python-facing API (pysrc/) over a Rust core (src/) split into serialize and deserialize modules plus ffi glue and a typeref.rs module that caches references to Python type objects (dataclass, datetime, UUID, numpy) to avoid repeated attribute lookups on the hot path; PyO3 handles the CPython/Rust boundary. Tech Stack - Rust (Cargo.toml/Cargo.lock pin the toolchain and dependencies) built via build.rs into a CPython extension module, published as prebuilt wheels for CPython 3.10-3.15 across six CPU architectures and three OSes. Code Quality - the test/ directory contains 34 Python test modules covering dataclasses, datetime, numpy, UUID, fragments, and option flags, plus a bench benchmark suite comparing against json and other libraries; the project has no public issue tracker (by design, to reduce noise) which means quality is enforced primarily through the maintainer’s own test/benchmark discipline rather than community triage. API Design - the dumps/loads surface intentionally mirrors the standard library’s json module for near drop-in migration, while option flags (rather than kwargs sprawl) control serialization behavior like non-str keys, UTC handling, and numpy array support, keeping the public API small and stable under its semver-as-breaking-change policy.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers