YourFileKit
Esc
Log in
Text & Writing

Slugs, Titles, and Filenames: The Different Rules for 'Clean' Text

A page title, a URL slug, and a filename all start from the same string of text, but each one is constrained by different rules about what characters are actually safe to use.

September 5, 20266 min read

Type the same sentence into a page title field, a URL slug field, and a "save as" filename dialog, and each one has different opinions about what's actually allowed - not because of arbitrary inconsistency, but because each one is solving a different technical problem.

Quick answer: A title has almost no character restrictions because it's meant to be read, not parsed by a system. A URL slug needs to survive being part of a web address, so it's conventionally lowercased, hyphenated, and stripped of punctuation that would otherwise need percent-encoding. A filename has to survive a specific operating system's file system, which reserves certain characters outright and can fail a save rather than just look wrong. The same source text needs a different transformation for each destination.

What "slugifying" text actually means

Slugifying is the process of converting a string of human-readable text into a constrained, machine-safe version of it: lowercasing every letter, replacing spaces and most punctuation with hyphens, and dropping anything that isn't a plain ASCII letter, digit, or hyphen. The goal is a string that needs no further encoding or escaping no matter where it ends up, a URL path, a filename, a database key, because everything risky has already been removed up front rather than being handled reactively later.

A title has almost no real constraints

A page title or heading can contain almost anything: capital letters, punctuation, symbols, even emoji in many contexts. It exists to be read by a person, and the software displaying it generally just renders whatever string it's given. This is why it's the least fussy of the three - "Q3 Report: Revenue & Growth (Final)" is a perfectly normal title.

Where a title's freedom actually causes downstream trouble

The friction doesn't show up at the title itself, it shows up the moment something else (a URL, a filename, a database record) is generated from that title automatically. A content system that auto-generates a page's URL from its title, or a script that names an exported file after a document's heading, is exactly where the colon, ampersand, or emoji that was perfectly fine in the title suddenly becomes a problem two steps downstream, which is the whole reason slug and filename conversion exists as a separate step rather than just reusing the title text directly.

A URL slug has to survive being part of a web address

A slug is the part of a URL that identifies a specific page - and URLs have real technical restrictions on what characters are safe to include without being encoded into escape sequences. Spaces, ampersands, colons, and most punctuation either aren't allowed directly or get converted into %20-style encoded gibberish, which is exactly what a clean slug avoids by removing them up front instead. The near-universal convention lowercases everything and replaces spaces with hyphens - "q3-report-revenue-and-growth" - readable, shareable, and unambiguous across every browser and server.

Text to Slug Converter does exactly this conversion - stripping the punctuation a URL can't safely carry and normalizing the rest into the hyphenated, lowercase form every URL convention expects.

What percent-encoding looks like when you skip the slug step

If a URL is built directly from unconverted text instead of a slug, unsafe characters don't cause an outright failure, they get automatically percent-encoded: a space becomes %20, an ampersand becomes %26, and so on. The link still technically works, but it's much less readable when typed, shared in a message, or read aloud, and it's easy to introduce a subtle bug by double-encoding a URL that was already encoded once. URL Encoder / Decoder is useful for seeing exactly what that encoded form looks like and decoding it back, which makes the case for a clean slug concrete rather than abstract: it's not that percent-encoded URLs don't work, it's that a slug is designed to never need them in the first place.

A filename has to survive a specific operating system

A filename's constraints come from the file system, not the web, and they're stricter and more varied: Windows reserves \ / : * ? " < > | outright, and both Windows and macOS have their own additional quirks around trailing periods, reserved names, and maximum length. A title with a colon in it - "Report: Final" - saves fine as a document title but can fail outright as a filename on some systems, not just look wrong.

Cross-platform filenames need the strictest common subset

A file created on one operating system often needs to survive being opened, copied, or shared on a different one, which means the safe approach is designing for the strictest rules among the systems involved rather than just the one you're currently using. A filename that saves fine on macOS but contains a colon or a reserved name like CON or NUL can fail the moment it's copied to a Windows machine or synced through a cloud drive that enforces Windows-compatible naming. Sticking to letters, digits, hyphens, and underscores sidesteps every operating system's reserved-character list at once, rather than needing to memorize each one individually.

Case conversion is the tool underneath all of this

Once punctuation is handled, the remaining question is often just what casing convention a target system expects - kebab-case for a slug, snake_case for some filenames and programming contexts, camelCase for others. Case Converter handles that half of the problem directly, converting the same base text between the casing styles different systems actually expect.

Common mistakes when converting between the three

Reusing a title as a slug without stripping punctuation. A slug generated by naively lowercasing and space-replacing a title without removing other punctuation first can end up with stray characters that still need encoding, defeating the point of slugifying at all.

Assuming a filename that works locally will work everywhere. A filename with a character your current operating system tolerates can still break the moment it's shared, synced to a different platform, or served from a URL path directly.

Not handling slug collisions. Two different titles can produce an identical slug once punctuation is stripped, and a system that doesn't check for that can silently let a new page overwrite an existing URL rather than flagging the collision.

The short version

The "same" piece of text needs three different treatments depending on where it's headed: a title just needs to be readable, a slug needs to survive being part of a URL, and a filename needs to survive a specific file system's own reserved characters. Converting deliberately for each destination avoids three different classes of subtle breakage that "just typing it in" doesn't protect against. Text to Slug Converter, URL Encoder / Decoder, and Case Converter each handle one piece of that conversion directly.

Frequently asked

Can a URL slug contain uppercase letters?

Technically URLs can, but lowercase is the near-universal convention, mainly because some server configurations treat URL paths as case-sensitive and some don't - staying consistently lowercase sidesteps the whole issue and avoids two URLs that differ only by case being treated as different pages by some systems and the same page by others.

Why do slugs use hyphens instead of underscores?

Search engines historically treated a hyphen as a word separator (turning 'blue-widgets' into the two words 'blue' and 'widgets' for indexing) but treated an underscore as part of the word itself. That distinction has narrowed over time, but hyphens remain the entrenched convention for exactly that reason.

Is it safe to reuse a title with special characters as a filename?

Not always - characters like /, \, :, *, ?, ", <, >, and | are reserved by one operating system or another and can cause a save to fail outright rather than just look ugly. Converting to a plain slug-safe filename avoids the failure entirely rather than discovering it case by case.

What's the actual difference between a slug and percent-encoding?

A slug is a deliberate rewrite, punctuation and spaces are removed or replaced up front so the result never needs encoding. Percent-encoding is what happens automatically when a character that isn't safe in a URL gets converted into a %XX escape sequence instead, spaces become %20, for example. A clean slug is designed to need zero percent-encoding; text that isn't slugified relies on the browser or server to encode it for you, which is legible in a browser's address bar but ugly in a shared or typed link.

Do spaces in a filename actually cause problems, or is that outdated advice?

Spaces work fine on modern desktop operating systems, but they still cause real friction elsewhere: a space in a filename passed to a command line has to be quoted or escaped, and a filename with a space that ends up embedded in a URL (a file served directly from a web path, for instance) gets percent-encoded into %20, which is exactly the ugly-URL problem a slug avoids. Replacing spaces with hyphens or underscores sidesteps both cases at once.

Can two different titles produce the same slug by accident?

Yes, and it's a common content-management problem. 'Best Pizza Recipes!' and 'Best Pizza Recipes?' both slugify down to 'best-pizza-recipes' once punctuation is stripped, since the punctuation that made them visually distinct as titles carries no information in the slug. Systems that generate slugs automatically usually handle this by appending a number or short suffix when a collision is detected, rather than allowing two pages to silently claim the same URL.

More in Text & Writing

Text & Writing

More guides like this

Practical, tool-linked how-tos across PDF, image, finance, video, and more, no signup to read them.

Browse all articles