pathvalidate
pathvalidate is a Python library to sanitize/validate a string such as filenames/file-paths/etc.
Decision gist · record as of 2026-08-14
Yes. pathvalidate is a focused, well-maintained library with zero dependencies, permissive licensing, and active development. Install it if you need reliable filename or path validation across platforms; the low friction and clear API make it a straightforward addition to any project handling file I/O.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction: zero runtime dependencies, pure Python wheel distribution.
- Actively maintained with recent commits and stable production status.
License · maintenance · safety
MIT License (permissive) — MIT License (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2025-06-15 (425 days) · last repo commit 2026-05-10 · 294 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 20,577,101 downloads/mo, #1,032 on PyPI
Alternatives
Verify before relying
pip install pathvalidate
from pathvalidate import sanitize_filename, validate_filename
fname = "fi:l*e/p\"a?t>h|.t<xt"
print(sanitize_filename(fname)) # Returns valid filename
validate_filename(fname) # Raises ValidationError if invalid- Whether multibyte character support covers all Unicode normalization edge cases across platforms.
- Performance characteristics when sanitizing very long paths or batch processing large filename lists.
What it is and what it does
pathvalidate is a Python library that cleans and validates filenames and file paths by removing or replacing characters that are invalid, reserved, or unprintable on target platforms. It handles platform-specific rules for Linux, Windows, macOS, POSIX, and universal (cross-platform) contexts, and includes support for multibyte characters. The library provides both standalone functions and integrations with argparse and click for command-line argument validation and sanitization.
You use it when you need to accept user input or external data as filenames or paths and ensure they will work on your target platform without errors. It removes problematic characters, replaces reserved names (like COM1 on Windows), normalizes whitespace, and strips unprintable characters—all without external dependencies.
Use it for
- Sanitize user-supplied filenames in web applications or file upload handlers before writing to disk.
- Validate file paths in CLI tools using argparse or click to reject invalid input early.
- Clean batch-imported filenames from external sources (APIs, databases, archives) for cross-platform compatibility.
- Normalize path strings in data pipelines to prevent filesystem errors across development, staging, and production environments.
- Check whether a string is a valid filename before attempting file operations to provide clear error messages.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pathvalidate is a focused, well-maintained library with zero dependencies, permissive licensing, and active development. Install it if you need reliable filename or path validation across platforms; the low friction and clear API make it a straightforward addition to any project handling file I/O.
Install
pathvalidate on PyPI
Before you install
Low friction: zero runtime dependencies, pure Python wheel distribution. Actively maintained with recent commits and stable production status.
Requires Python 3.9 or later.
License in practice
MIT License (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pathvalidate
from pathvalidate import sanitize_filename, validate_filename
fname = "fi:l*e/p\"a?t>h|.t<xt"
print(sanitize_filename(fname)) # Returns valid filename
validate_filename(fname) # Raises ValidationError if invalid
Verify before relying
- Whether multibyte character support covers all Unicode normalization edge cases across platforms.
- Performance characteristics when sanitizing very long paths or batch processing large filename lists.
Package facts
| License | MIT License permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 425 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 20,577,101 / month, #1,032 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 :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: FilesystemsTopic :: Text ProcessingTyping :: Typed |
Evidence: pathvalidate-3.3.1-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 › “sanitize file paths”
- pathvalidateSanitize and validate filenames and file paths by removing or…
- sanitize-filenameRemoves or replaces problematic characters from filenames while…
- django-summernoteEmbeds the Summernote WYSIWYG editor into Django admin and forms,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
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.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
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.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also sanitize-filename · msgfy · html-sanitizer · pathtools · iregexp-check · eradicate · wheel-filename · nh3 · pgsanity · strip-ansi