--- id: bitstring version: "4.4.0" license: MIT license_treatment: permissive maintenance: active --- # bitstring — Simple construction, analysis and modification of binary data. License: permissive · Maintenance: active · Downloads: 5.9M/mo ## 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 above — 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 pip install bitstring uv add bitstring 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_current - Install friction: low - Maintenance: active - Downloads: 5.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags binary data manipulation python, bit-level operations, bitarray packing unpacking, binary parsing and creation, hex binary octal conversion, bitstream reading writing, fixed-length bit arrays, binary-data, bit-manipulation, protocol-parsing [View on SkillFed](https://skillfed.io/packages/bitstring) · [View on PyPI](https://pypi.org/project/bitstring/)