Binary Extensions
Check if a file or extension is binary, and iterate over 250+ known binary file types including images, videos, archives, and executables. Python port of binary-extensions npm package.
Features
- Immutable collection of hundreds of known binary file extensions
- Fast membership checks using
frozenset - Case-insensitive and dot-aware checks
- Works for both extensions and full file paths
- Supports dotfiles (e.g.,
.DS_Store) - Zero dependencies, minimal overhead
Installation
pip install binary-extensions
Or using uv:
uv add binary-extensions
Usage
Check if an extension is binary
from binary_extensions import is_binary_extension
is_binary_extension("png") # True
is_binary_extension(".jpg") # True (dot-aware)
is_binary_extension("PDF") # True (case-insensitive)
is_binary_extension("txt") # False
Check if a file path has a binary extension
from binary_extensions import is_binary_path
is_binary_path("image.png") # True
is_binary_path("/path/to/file.JPG") # True (case-insensitive)
is_binary_path("document.pdf") # True
is_binary_path("document.txt") # False
is_binary_path(".DS_Store") # True (dotfile support)
Access the list of binary extensions
from binary_extensions import BINARY_EXTENSIONS, BINARY_EXTENSIONS_LOWER
# BINARY_EXTENSIONS is a frozenset of all known binary extensions
print(len(BINARY_EXTENSIONS)) # Number of supported extensions
"png" in BINARY_EXTENSIONS # True
"txt" in BINARY_EXTENSIONS # False
# BINARY_EXTENSIONS_LOWER contains all extensions in lowercase
# Useful for case-insensitive lookups without calling .lower() repeatedly
"PNG" in BINARY_EXTENSIONS_LOWER # True (case-insensitive)
Supported Extensions
The package includes support for hundreds of binary file extensions, including:
- Images: png, jpg, gif, bmp, webp, svg, ico, and more
- Audio: mp3, wav, flac, aac, ogg, and more
- Video: mp4, avi, mkv, mov, webm, and more
- Archives: zip, tar, gz, 7z, rar, and more
- Documents: pdf, doc, docx, xls, xlsx, ppt, pptx, and more
- Executables: exe, dll, so, dmg, appimage, and more
- Fonts: ttf, otf, woff, woff2, and more
- And many more...
Credits
This package is a Python port of the binary-extensions npm package by Sindre Sorhus.
Changelog
See CHANGELOG.md for a detailed list of changes and version history.
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, development setup, and the process for submitting pull requests.
Support
If you find this library useful, please consider:
- ⭐ Starring the repository on GitHub to help others discover it.
- 💖 Sponsoring to support ongoing maintenance and development.
Become a Sponsor on GitHub | Support on Patreon
License
MIT License - see LICENSE file for details.
Author
Y. Siva Sai Krishna
- GitHub: @ysskrishna
- LinkedIn: ysskrishna
Metadata
Release files for binary-extensions 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| binary_extensions-1.0.1.tar.gz | 17.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| binary_extensions-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.7 kB
Release files / binary_extensions-1.0.1.tar.gz
| Download URL | binary_extensions-1.0.1.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6db01c1c5697ef9fd657c5489955c972c7089b3e533ed1330e566a23bd601994
|
|
BLAKE2b-256 checksum How to use checksums |
fa1cd6e2ee02a43449f416c6044e4599366257624d52279fa1216ddd0a25b94f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / binary_extensions-1.0.1-py3-none-any.whl
| Download URL | binary_extensions-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8b129bc12ffb2029c926b1af5da86ecbdc317b7f644b15ac481f139ffb59506
|
|
BLAKE2b-256 checksum How to use checksums |
b9240357d114522e7c6ff1c5102e3ef4146b3f3cb82da5ff05470bac4bcb08fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|