binaryornot
Ultra-lightweight pure Python package to check if a file is binary or text.
Decision gist · record as of 2026-08-14
Yes. Zero dependencies, actively maintained, MIT-licensed, and solves a real problem that naive byte-checking approaches get wrong. Install it if you need reliable binary/text classification in any Python tool or pipeline.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later
- Low friction: zero runtime dependencies, pure Python wheel, actively maintained with a recent release.
- Last commit 2026-05-19 and marked Production/Stable.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2026-03-08 (159 days) · last repo commit 2026-05-19 · 149 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 23,972,593 downloads/mo, #930 on PyPI
Alternatives
Verify before relying
pip install binaryornot
from binaryornot.check import is_binary
is_binary("image.png") # True
is_binary("README.md") # False- Whether the decision tree model is retrained or updated with new file formats over time
- Performance characteristics on very large files or high-throughput scanning scenarios
What it is and what it does
BinaryOrNot is a lightweight pure-Python library that classifies files as binary or text by reading the first 128 bytes and running them through a trained decision tree. Unlike naive approaches that check for null bytes, it accounts for multi-byte text encodings (UTF-16, Big5, GB2312), BOM markers, Shannon entropy, and byte ratios—correctly handling edge cases where simple heuristics fail. It ships with zero dependencies and works as both a Python API and a command-line tool.
The package is designed for scenarios where you need reliable file-type detection without external tools or heavy machinery: filtering files in batch processing, deciding whether to treat content as text or binary in version control or build systems, or validating input before parsing. It has been tested against 37 text encodings and 49 binary formats.
Use it for
- Filter files in a directory walk to process only text files, skipping images and compiled binaries
- Pre-flight check in a build or CI tool to reject binary files before attempting text-based parsing
- Decide whether to show a file diff in a version control UI or mark it as binary
- Validate user uploads to ensure they are text before feeding them to a text processor
- Identify encoding issues in mixed-encoding datasets by classifying files before conversion
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Zero dependencies, actively maintained, MIT-licensed, and solves a real problem that naive byte-checking approaches get wrong. Install it if you need reliable binary/text classification in any Python tool or pipeline.
Install
binaryornot on PyPI
Before you install
Low friction: zero runtime dependencies, pure Python wheel, actively maintained with a recent release. Last commit 2026-05-19 and marked Production/Stable.
Requires Python 3.10 or later
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install binaryornot
from binaryornot.check import is_binary
is_binary("image.png") # True
is_binary("README.md") # False
Verify before relying
- Whether the decision tree model is retrained or updated with new file formats over time
- Performance characteristics on very large files or high-throughput scanning scenarios
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 159 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 23,972,593 / month, #930 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Typing :: Typed |
Evidence: binaryornot-0.6.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “binary file detection”
- binaryornotDetermines whether a file is binary or text by analyzing its byte…
- isbinaryDetermines whether a file is binary or text by analyzing its content…
- typecode-libmagicProvides a prebuilt native libmagic binary and database as a ScanCode…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also isbinary · RoffIO · mbstrdecoder · chardet · mikeshardmind-base2048 · x690 · cigam · cchardet · faust-cchardet · bincopy