Binary Extensions

Check if a file or extension is binary with 250+ known binary types

Flag binary-looking paths by extension, no extra dependencies

When it’s useful

Upload validation, scanners, and file workflows often need a fast “probably binary” signal before deeper inspection. Rolling your own extension list is easy to get wrong. This library mirrors the well-known binary-extensions npm dataset in Python so you can treat archives, media, executables, and similar types consistently.

What you can do

  • Check an extension or a full path for a binary type, with case-insensitive, dot-aware matching (including dotfiles such as .DS_Store).
  • Use a curated immutable set: 250+ binary extensions across images, audio, video, archives, documents, fonts, and executables.
  • Keep checks cheap with frozenset membership.
  • Expose the sets (BINARY_EXTENSIONS, BINARY_EXTENSIONS_LOWER) for custom filtering or reporting.

Limits and fit

This is extension-based heuristics, not magic-byte sniffing. A .txt file could hold binary data and a misnamed file could slip through; pair with real validation when security or correctness demands it. Python 3.8+; install from PyPI (binary-extensions). Full API and changelog are in the GitHub repository.

Frequently asked questions

What is Binary Extensions?

It is a zero-dependency Python port of the binary-extensions npm dataset. You check whether an extension or full path looks binary using a curated immutable set of 250+ binary extensions.

How do checks work?

Matching is case-insensitive and dot-aware, including dotfiles such as .DS_Store. Membership uses a frozenset, and you can import BINARY_EXTENSIONS or BINARY_EXTENSIONS_LOWER for custom filtering.

How do I install it?

Requires Python 3.8+. Install from PyPI with pip install binary-extensions.

Does it sniff file contents?

No. It is extension-based heuristics, not magic-byte sniffing. A .txt file could hold binary data and a misnamed file could slip through, so pair it with real validation when security or correctness matters.

Continue exploring