Skip to main content

safe-file-name-generator

A safe file name is one that survives every filesystem and URL it might pass through β€” Windows (no <>:"|?* or reserved names like CON, NUL), macOS (no colons), Linux (no slashes / null bytes), S3 (no spaces if you want clean URLs), URLs (no spaces or non-ASCII without encoding). The ZTools Safe File Name Generator takes a free-form string and produces a file name that's legal everywhere. Configurable: lowercase or preserve case, replace spaces with - or _, transliterate accents (cafΓ© β†’ cafe), keep extension, drop or trim length, prepend a date.

Use cases​

Sanitize user-uploaded file names​

A user uploads "RΓ©sumΓ© - Final (v3) <draft>.pdf". Save as resume-final-v3-draft.pdf to avoid filesystem and URL trouble.

Generate IDs for a static file storage​

Each blog post needs a permanent slug-like name. Generator turns the title into a stable, lowercase, dash-separated name.

Build batch-rename rules​

Apply a consistent naming convention across 1000 files (date prefix + slug). Generator outputs the new names; rename script applies them.

Prevent filename collisions​

Two uploads named "Document.pdf" β€” the second overwrites the first. Add a date / hash prefix to disambiguate.

How it works​

  1. Paste source name β€” Free-form string with any characters.
  2. Pick rules β€” Lowercase, replace spaces (-, _, or remove), strip illegal chars, transliterate accents, keep / drop extension, max length, date prefix.
  3. Generate β€” Tool applies rules in order. Shows before / after, plus list of platforms the result is safe for.
  4. Copy result β€” Single name or batch (paste a list, get a list of safe names).

Examples​

Input: "RΓ©sumΓ© - Final (v3) <draft>.pdf"

Output: resume-final-v3-draft.pdf β€” accents stripped, illegal chars removed, parens dropped, lowercased, dashes between words.


Input: "My Photo (1).jpg" with date prefix

Output: 2026-05-06-my-photo-1.jpg β€” sortable by date, unique within the day, URL-safe.


Input: Reserved-name detection: "CON.txt"

Output: Windows reserved! Suggested rename: con-file.txt. Generator warns and offers a fix.

Frequently asked questions​

What characters are illegal where?

Windows: < > : " / \ | ? * + reserved names (CON, PRN, AUX, NUL, COM1-9, LPT1-9). macOS: : (slash internally, colon at API level). Linux: / and null. URLs: spaces and most non-ASCII unless encoded.

Why transliterate accents?

Some platforms (older S3, some Linux fs without UTF-8 locale) mangle accented characters. Transliteration (cafΓ© β†’ cafe) prevents that. Skip if your target supports UTF-8 fully.

Is the result reversible?

No β€” once "cafΓ©" becomes "cafe", you can't recover the accent. Store the original in a database column if you need it for display.

What about emoji in file names?

Most filesystems handle them since UTF-8 became standard. Generator can preserve or strip β€” toggle per use case.

Privacy?

All processing in browser.

Maximum length?

NTFS / APFS: 255 chars. ext4: 255 bytes. URL: 2,000 in practice. Generator defaults to 100 β€” covers all platforms with margin.

Tips​

  • Always transliterate to ASCII for maximum portability β€” UTF-8 works in modern systems but breaks in legacy ones.
  • Use date prefix (YYYY-MM-DD-) for sortability β€” alphabetical sort gives chronological order.
  • Strip Windows reserved names defensively β€” even on macOS / Linux, the file might end up on a Windows backup drive.
  • Keep extensions intact β€” strip-and-rename without preserving .pdf breaks every consumer.

Try it now​

The full safe-file-name-generator runs in your browser at https://ztools.zaions.com/safe-file-name-generator β€” no signup, no upload, no data leaves your device.

Open the tool β†—


Last updated: 2026-05-06 Β· Author: Ahsan Mahmood Β· Edit this page on GitHub