skillfed

bitstring

Simple construction, analysis and modification of binary data.

bitstring v4.4.0 5.9M downloads/30d#2,014 on PyPI446
Permissive license MIT Active released

What it is and what it does

bitstring is a Python library for working with binary data at the bit level. It lets you create bitstrings from hex, octal, binary, bytes, integers, floats, and files, then manipulate them through slicing, searching, replacing, and packing operations. The library provides idiomatic Python classes (Bits, BitArray, BitStream) and utility functions, making bit-level work feel natural rather than low-level.

The package is production-stable and has been actively maintained since 2006. It depends on bitarray and tibs (a newer Rust-based rewrite of the core, currently in beta). The library supports Python 3.8 through 3.14 and is widely used—it ranks in the top 5000 PyPI packages by download volume. It's particularly useful for tasks like binary protocol parsing, data serialization, and bit manipulation in embedded or network contexts.

Use it for:

  • Parse binary network protocols or file formats by creating bitstrings from hex/binary and extracting fields via bit-level slicing.
  • Pack and unpack structured binary data (e.g., multi-format fields) using the pack function with endianness control.
  • Search for and replace bit patterns within binary data, useful for binary data transformation pipelines.
  • Read and interpret binary streams sequentially, tracking position and reading typed chunks (uint, float, etc.).
  • Create and manipulate arrays of fixed-length bitstrings for efficient storage of homogeneous binary records.

Worth the install?

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

bitstring provides Python classes and functions to create, manipulate, and interpret binary data at the bit level, with support for multiple input formats and bit-level operations like slicing, searching, and packing.

Yes. bitstring is production-stable, actively maintained, has no known vulnerabilities, and low install friction. It's the standard choice for bit-level binary manipulation in Python. Install it if you need to work with binary protocols, data formats, or bit-level operations; the API is well-documented and the library is widely trusted in the community.

Install

bitstring on PyPI

pip

pip install bitstring

uv

uv add bitstring

poetry

poetry add bitstring

Installing bitstring

Before you install

Low install friction with a pure-Python wheel distribution. Actively maintained since 2006 with a recent release 157 days ago; the project has 446 repository stars and remains under active development.

License in practice

Released under the MIT license (permissive), which permits commercial and private use with minimal restrictions—suitable for most projects without licensing concerns.

Quickstart

pip install bitstring

from bitstring import BitArray, Bits, pack
a = BitArray(bin='00101')
b = Bits('0xff, 0b101, 0o65')
c = pack('intle16, hex=a', 100, a='0x34f')
print(a.hex, a.bin, a.uint)

Verify before relying

  • Performance characteristics when handling very large binary datasets or streaming scenarios.
  • Compatibility guarantees between bitstring and its new Rust-based sibling tibs package.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — bitarray, tibs
Maintenance actively maintained — 157 days since the last release
Last repo commit
First released
Downloads 5,910,491/month — #2,014 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: bitstring-4.4.0-py3-none-any.whl

Keywords: binary, bitarray, bitvector, bitfield

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

binary data manipulation pythonbit-level operationsbitarray packing unpackingbinary parsing and creationhex binary octal conversionbitstream reading writingfixed-length bit arrays
binary-databit-manipulationprotocol-parsing

More Python Modules packages