skillfed

bson

BSON codec for Python

bson v0.5.10 967.2K downloads/30d#4,617 on PyPI467
Permissive license BSD AGING released

What it is and what it does

bson is a standalone BSON codec for Python that does not require MongoDB to be installed. It provides functions to serialize Python dictionaries and other objects into BSON binary format and deserialize BSON back into Python objects. The package also includes utilities for sending and receiving BSON objects over network sockets by patching the socket module.

The package is useful when you need to work with BSON data outside of a MongoDB context—for example, when interoperating with other systems that use BSON as a data format, or when you want BSON serialization without the full MongoDB driver. It has no runtime dependencies, making it lightweight to add to a project.

Use it for:

  • Serialize and deserialize BSON data in standalone Python applications that need to exchange data with BSON-based systems.
  • Communicate BSON objects over network sockets between Python processes or services.
  • Parse BSON-formatted data from files or external sources without installing MongoDB.
  • Embed BSON encoding/decoding in tools that work with MongoDB exports or BSON-compatible APIs.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Encodes and decodes BSON (Binary JSON) data independently of MongoDB, and can serialize BSON objects over network sockets.

No—not recommended for new projects. The package has not been updated since 2020-05-26 and targets Python versions (2.6–3.6) that are no longer supported. Compatibility with modern Python (3.7+) is undocumented and likely broken. If you need BSON support, consider using the official pymongo library's BSON codec instead, which is actively maintained.

Install

bson on PyPI

pip

pip install bson

uv

uv add bson

poetry

poetry add bson

Installing bson

Before you install

High install friction: the package has not been updated since 2020-05-26 and is classified as aging. It targets Python 2.6 through 3.6, which are no longer actively supported. Compatibility with modern Python versions is unspecified.

License in practice

Licensed under BSD (permissive), which allows use in most projects without restriction, but you should verify the specific BSD variant matches your compliance requirements.

Quickstart

pip install bson

import bson
a = bson.dumps({"A": [1, 2, 3, 4, 5, "6", "7", {"C": "DS"}]})
b = bson.loads(a)

Package targets Python 2.6–3.6; compatibility with Python 3.7+ is not documented and may be broken.

Verify before relying

  • Whether this package works reliably on Python 3.7 and later versions despite classifier claims ending at 3.6.
  • Active maintenance status and whether the repository accepts pull requests or is effectively unmaintained.
  • Whether the socket patching feature (bson.patch_socket) is still functional and tested.

Package facts

License BSD (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance aging — 2,271 days since the last release
Last repo commit
First released
Downloads 967,185/month — #4,617 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: bson-0.5.10.tar.gz

Keywords: BSON, codec

Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6

Tags

bson encoder decoderbinary json codecbson serializationmongodb data format without mongodbbson socket communicationbson python library
serializationlegacy

More Database packages