Filename Sanitizer

Paste a list of filenames and get back a cleaned-up version that will survive any operating system, any ZIP archive, any CDN path. The sanitizer converts accented letters to plain ASCII, strips characters that break on Windows (\ / : * ? " < > |), removes control characters, collapses whitespace and replaces forbidden sequences with your chosen replacement (default: hyphen). Useful before bulk-uploading to S3, shipping a courseware ZIP, or fixing an import of photos off an old NAS.

How to sanitize filenames

  1. 1

    Paste the filenames

    One per line, with or without extensions. Extensions are preserved as-is.

  2. 2

    Choose the replacement

    Pick the character used to replace unsafe sequences. Hyphen (`-`) is the safest default; underscore (`_`) is the retro choice.

  3. 3

    Run the sanitizer

    Each name is trimmed, converted to ASCII, stripped of forbidden characters and collapsed whitespace. A name with nothing left becomes `file`.

  4. 4

    Review before renaming

    Output lists only the cleaned names, so scan it for collisions (two inputs becoming the same output) before renaming in place.

What is unsafe, and why

Different filesystems and tools have different blacklists. The safe cross-platform intersection is tighter than most people realize.

Characters and patterns that make filenames unsafe

Item Why it is unsafe
\ / : * ? " < > | Forbidden on Windows (NTFS, FAT).
ASCII control chars 0x00-0x1F Illegal on most filesystems; break shell scripts.
Leading/trailing spaces Silently stripped by Windows; invisible bugs.
Trailing dots Silently stripped by Windows.
Reserved names CON, PRN, AUX, NUL, COM1..9, LPT1..9, all blocked on Windows.
Unicode combining marks Cause café to look the same as café but be a different filename on some systems.
Emoji and pictograph glyphs Survive modern systems but break older CI pipelines and CDN paths.

Normalization steps applied

  1. ASCII conversion. Accented letters become their plain base: café becomes cafe, naïve becomes naive. Scripts without an ASCII equivalent (CJK, emoji) are dropped.
  2. Forbidden characters replaced. \ / : * ? " < > | and control characters become your replacement character (default: hyphen).
  3. Whitespace collapse. Runs of spaces and tabs become a single replacement character.
  4. Edge trimming. Leading and trailing dots and replacement characters are removed; an empty result becomes file.
  5. Extensions preserved. Dots inside the name are not replaced, so .pdf, .jpg, .tar.gz survive; only trailing dots are trimmed.

Tips

  • Keep the extension. Dots inside a name are kept, so .pdf, .jpg, .tar.gz survive as-is.
  • Check for collisions. Résumé.pdf and Resume.pdf both become resume.pdf, because accents are always converted. Review the output before renaming in place.
  • Web paths. For URLs, also percent-encode after sanitizing, or better, keep the URL slug a subset of [a-z0-9-] so encoding is never needed.

Frequently Asked Questions

For web assets and cross-platform ZIPs, yes, it avoids subtle bugs when a file is uploaded to a case-insensitive Windows server and linked from a case-sensitive Linux CDN. The sanitizer never changes letter case, so lowercase names yourself when you need it. For local work it is taste.

Spaces are legal on every modern OS but they force URL encoding (%20), break many shell pipelines and confuse older tools. Replacing them with a hyphen eliminates a whole category of bugs.

The sanitizer always outputs plain ASCII: accented Latin letters are transliterated (café becomes cafe), Cyrillic is converted to a Latin approximation, and characters without an ASCII equivalent (CJK, Thai, emoji) are dropped. If a target system needs the original non-Latin names, keep them in a separate file.

No, the list is sanitized in memory during the request and is not stored or written to any log afterwards.

Related Tools

Tool available in other languages