orjson
orjson is a fast and correct Python JSON library supporting dataclasses, datetimes, and numpy. The current version is 3.11.7, released on March 28, 2026, with a release cadence of approximately every 3 months.
Warnings
- breaking orjson 3.11.7 introduces a breaking change in the deserialization function, requiring explicit UTF-8 encoding for JSON input.
- gotcha Using orjson.dumps() on non-serializable objects will raise a TypeError.
Install
-
pip install orjson
Imports
- orjson
import orjson
Quickstart
import orjson
# Serialize a Python object to JSON
data = {'name': 'Alice', 'age': 30}
json_bytes = orjson.dumps(data)
json_str = json_bytes.decode('utf-8')
print(json_str)
# Deserialize JSON to a Python object
json_bytes = b'{"name":"Alice","age":30}'
parsed_data = orjson.loads(json_bytes)
print(parsed_data)