sanitize-filename
A permissive filename sanitizer.
Decision gist · record as of 2026-08-14
Yes, if you need quick filename sanitization and accept the blacklist trade-off. The package is simple, dependency-free, and handles most common cases well. However, the project is abandoned (last release April 2020), so it will not receive security updates or bug fixes. Use it for non-critical applications or where you can audit and maintain the code yourself if needed.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.7 or later.
- Installation is frictionless—no runtime dependencies and a pure Python wheel.
- However, the package is abandoned; the last release was 2020-04-24 and no maintenance activity is evident, so security or compatibility issues would not be addressed.
License · maintenance · safety
permissive license (permissive) — Licensed under MIT (permissive), so you may use, modify, and distribute the package freely in commercial or private projects with minimal restrictions.
last release 2020-04-24 (2303 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 351,053 downloads/mo, #7,325 on PyPI
Alternatives
Verify before relying
pip install sanitize-filename
from sanitize_filename import sanitize
filename = sanitize("A/B/C.txt")
print(filename) # 'ABC.txt'- Whether the blacklist approach adequately handles all filesystem-specific reserved names and characters across Windows, macOS, and Linux in practice.
- Whether non-ASCII character preservation works correctly with all Unicode normalization edge cases.
What it is and what it does
sanitize-filename is a lightweight, dependency-free library that cleans filenames by removing or replacing characters that are problematic for filesystems. It uses a blacklist strategy—filtering out forbidden characters rather than allowing only safe ones—which means it preserves the original filename and non-ASCII characters as much as possible. This makes it useful when you want to keep user-supplied or original filenames intact while still avoiding filesystem errors.
The package handles common gotchas like reserved names (NUL, CON, etc.), leading/trailing dots, and path separators. However, the documentation explicitly warns that blacklist-based sanitization is inherently less safe than whitelist approaches; the authors recommend creating safe filenames yourself or using a whitelist strategy when security is paramount. This package is best suited for cases where preserving the original filename is a priority and you accept the trade-off in safety.
Use it for
- Sanitize user-uploaded filenames in web applications before storing them to disk.
- Clean filenames from external data sources or APIs while retaining non-ASCII characters for international names.
- Prepare filenames for cross-platform file operations without forcing ASCII-only names.
- Handle reserved filesystem names (like NUL or CON on Windows) in batch file processing.
- Validate and clean filenames in data import pipelines where preserving the original name is important.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need quick filename sanitization and accept the blacklist trade-off.
The package is simple, dependency-free, and handles most common cases well. However, the project is abandoned (last release April 2020), so it will not receive security updates or bug fixes. Use it for non-critical applications or where you can audit and maintain the code yourself if needed.
Install
sanitize-filename on PyPI
Before you install
Installation is frictionless—no runtime dependencies and a pure Python wheel. However, the package is abandoned; the last release was 2020-04-24 and no maintenance activity is evident, so security or compatibility issues would not be addressed.
Requires Python 3.7 or later.
License in practice
Licensed under MIT (permissive), so you may use, modify, and distribute the package freely in commercial or private projects with minimal restrictions.
Quickstart
pip install sanitize-filename
from sanitize_filename import sanitize
filename = sanitize("A/B/C.txt")
print(filename) # 'ABC.txt'
Verify before relying
- Whether the blacklist approach adequately handles all filesystem-specific reserved names and characters across Windows, macOS, and Linux in practice.
- Whether non-ASCII character preservation works correctly with all Unicode normalization edge cases.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release ~=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 2,303 days since the last release |
| First released | |
| Downloads | 351,053 / month, #7,325 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: sanitize_filename-1.2.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 › “filename sanitization”
- sanitize-filenameRemoves or replaces problematic characters from filenames while…
- pathvalidateSanitize and validate filenames and file paths by removing or…
- fold-to-asciiConverts Unicode characters outside the basic ASCII range into their…
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 pathvalidate · eradicate · html-sanitizer · fold-to-ascii · Unidecode · bleach-allowlist · nh3 · better-profanity · retrie · wheel-filename