ysskrishna logoysskrishna

Binary Extensions

Know which paths look binary in Python, from a curated list of 250+ extensions with no extra dependencies.

Built with
PyPI Packages
File & Path Utilities
Python
uv
PyPI
GitHub Actions
Pytest
Details
FreeMIT licenseCreated January 10, 2026Updated November 12, 2026
Share this product

You have a filename. You still do not know whether to treat it as binary.

A scanner hits thousands of paths. An upload lands with an odd name. A pipeline has to decide whether to open a file, quarantine it, or pass it along. Guessing from a short list you typed last year is how webp slips through and your weekend turns into list maintenance.

Binary Extensions gives you one shared answer: a curated set of 250+ binary extensions, ported from the binary-extensions npm package, in a small Python library you can drop in today.

Probably binary? Check the extension first.

What you get

  • A fast yes or no from the path alone. Check a bare extension or a full path before you spend time reading bytes.
  • One list that stays in sync with a familiar standard. You inherit hundreds of known binary types across images, video, archives, documents, fonts, and executables without writing JSON by hand.
  • Matching that survives real filenames. Case-insensitive, dot-aware checks, including dotfiles such as .DS_Store.
  • Cheap bulk filters. Membership lives in an immutable frozenset so directory walks and batch gates stay light.
  • The raw set when you need it. Import the full extension collection, or a lowercase copy, for custom rules and reporting.
  • No dependency chain. Zero third-party packages beyond the standard library you already run.

Picture your Tuesday

You are building a folder sweep before a deeper virus scan (an illustrative example). Every path gets one quick gate: if it looks binary by extension, it goes to the slow queue. If not, it can skip the heavy step. You are not claiming perfect security. You are stopping obvious media, archives, and executables from clogging the line.

Ready to try it?

Requires Python 3.8 or newer.

Frequently asked questions

Why not just sniff magic bytes or read the file contents?

That is the right tool when security or correctness depends on what is inside the file. This library does not open bytes. It answers a narrower question: does this path carry an extension that usually means binary? Use it as an early filter, then add real validation when the stakes are high.

Is there a Python version of the binary-extensions npm list?

Yes. It is a Python port of the binary-extensions npm package, with helpers to check extensions, check paths, and browse the full extension set.

How do I tell if a path is probably binary without opening it?

Pass the extension or the full path into the library’s check helpers. A match means the extension appears in the curated binary set. A miss means it is not on that list, not that the file is safe text.

Does it handle mixed-case extensions and dotfiles?

Yes. Checks are case-insensitive and dot-aware. Paths that are only a dotfile name, such as DS_Store style names, are treated as binary when the name matches the list.

Can I reuse the full extension list in my own filters?

Yes. You can import the immutable frozenset of all known binary extensions, or the lowercase copy, and use membership tests in your own code.

What do I need to run it?

Python 3.8 or newer. Install from PyPI with the project name binary-extensions, or add it with uv as shown in the repository readme.

Is it free?

Yes. It is open source under the MIT license, as listed on PyPI and in the repository readme.

Continue exploring

ProductText Extensions

Text Extensions

Know which paths look like text before you open them. One shared list, no list upkeep.
File & Path Utilities
PyPI Packages
Python
uv
ProductVideo Extensions

Video Extensions

A fast, honest first filter when a filename might be video.
File & Path Utilities
PyPI Packages
Python
uv
ProductUnused Path

Unused Path

Stop overwriting downloads and exports. Get the next free filename, browser style.
File & Path Utilities
PyPI Packages
Python
uv
ProductStrip BOM

Strip BOM

Invisible UTF-8 marks should not break your parsers, CSV headers, or string checks.
Text & Data Conversion
File & Path Utilities
PyPI Packages
Python
ProductSocial Links

Social Links

Users paste messy profile links. One Python library turns them into clean, comparable URLs.
PyPI Packages
Python
uv
PyPI
ProductNested Utils

Nested Utils

Deep JSON and config paths, one string, no guard maze.
PyPI Packages
Python
uv
PyPI