Last updated
Characters Removed or Replaced
- Windows-invalid:
\ / : * ? " < > | - Path traversal:
../and./sequences - Null bytes and control characters
- Leading/trailing dots and spaces
- Multiple consecutive spaces or hyphens (collapsed to one)
The File Name Sanitizer on TechConverter.me is an essential tool for any application that handles file uploads, generates file names from user input, or migrates files between operating systems — preventing errors, security vulnerabilities, and compatibility issues before they occur.
Examples
Example 1: User-Uploaded File Names
A file upload system receives these file names from users and sanitizes them before saving:
Input: "résumé (final version).docx"
Output: "resume-final-version.docx"
Changes: accented chars normalized, spaces → hyphens, parentheses removed
Input: "Report: Q1 2026 — Sales & Marketing.pdf"
Output: "report-q1-2026-sales-marketing.pdf"
Changes: colon removed (invalid on Windows), em dash → hyphen, ampersand removed
Input: "photo_2026/03/17.jpg"
Output: "photo_2026-03-17.jpg"
Changes: forward slashes replaced (path traversal prevention)
Input: "../../etc/passwd"
Output: "etc-passwd"
Changes: path traversal sequences removed (security)
Input: "file name with multiple spaces.txt"
Output: "file-name-with-multiple-spaces.txt"
Changes: multiple spaces collapsed and replaced with hyphens
Example 2: Windows Reserved Names
Windows reserves certain names as system device identifiers. The sanitizer detects and fixes them:
Input: "con.txt" → "con_.txt" (CON is a Windows device name)
Input: "prn.pdf" → "prn_.pdf" (PRN = printer device)
Input: "aux.log" → "aux_.log" (AUX = auxiliary device)
Input: "nul.json" → "nul_.json" (NUL = null device)
Input: "com1.config" → "com1_.config" (COM1 = serial port)
Input: "lpt1.txt" → "lpt1_.txt" (LPT1 = parallel port)
Example 3: URL-Safe File Names for CMS
A content management system generates URLs from file names. The sanitizer produces URL-safe names:
Input: "My Blog Post: 10 Tips & Tricks for 2026!"
Output: "my-blog-post-10-tips-tricks-for-2026"
URL: /posts/my-blog-post-10-tips-tricks-for-2026
Input: "Über die Bedeutung von Umlauten"
Output: "uber-die-bedeutung-von-umlauten"
URL: /posts/uber-die-bedeutung-von-umlauten
Input: "C# vs Java: Which Should You Learn?"
Output: "c-sharp-vs-java-which-should-you-learn"
URL: /posts/c-sharp-vs-java-which-should-you-learn