talira

Fast, correct JSON library for Python

open sourceMPL-2.0 AND (Apache-2.0 OR MIT)free

orjson is a JSON library for Python, written in Rust, that its README benchmarks as the fastest for Python and calls more correct than the standard json module. It serialises dataclasses, datetimes, numpy arrays and UUIDs natively; dumps() is about 10 times as fast as json and takes a default function and flags for output, and loads() is about twice as fast and strictly follows UTF-8 and RFC 8259. It supports CPython 3.10 to 3.15 with prebuilt wheels for Linux, macOS and Windows, and follows semantic versioning. Install it from PyPI as orjson.

Problems it solves

  • my Python API spends too long encoding JSON responses
  • serialise dataclasses and datetimes to JSON in Python without writing a custom encoder
  • dump numpy arrays to JSON quickly

Features

  • native serialisation of dataclasses, datetimes, numpy arrays and UUIDs
  • dumps() about 10x as fast as json
  • loads() about 2x as fast as json, strict UTF-8 and RFC 8259
  • default parameter and output flags
  • wheels for Linux, macOS and Windows on x86-64 and ARM

Limitations

  • Doesn't read or write files or line-delimited JSON itself.1
  • Doesn't support PyPy, embedded Python builds for Android or iOS, or PEP 554 subinterpreters.1

Alternatives

The same job

These do what orjson does.

  1. UltraJSON (ujson) Fast JSON encoder and decoder for Python, written in C

Compare orjson with the top 3