A slug is the readable, URL-safe identifier at the end of a web address. This tool converts any title or phrase into a clean slug by stripping accents, lowercasing, removing punctuation, and joining words with a single separator.
How it works
The conversion runs through a fixed pipeline:
1. Unicode-normalise to NFD, then remove combining marks (é → e)
2. Lowercase (optional)
3. Replace every run of non-alphanumeric characters with the separator
4. Trim leading and trailing separators
Normalising to NFD splits an accented character into its base letter plus a separate combining mark, which is then dropped. Collapsing all non-alphanumeric runs to one separator means spaces, commas, slashes, and emoji all turn into a single hyphen.
Worked examples
| Input | Slug |
|---|---|
Crème Brûlée: 10 Best Recipes! | creme-brulee-10-best-recipes |
What is GraphQL? | what-is-graphql |
Naïve user expectations — a designer's guide | naive-user-expectations-a-designers-guide |
café & restaurant reviews | cafe-restaurant-reviews |
Notice that the ampersand, em dash, and question mark all collapse to a single separator (or are trimmed if they land at the boundary).
Hyphens vs underscores — which to use
Choose hyphens for URLs in almost every case. Search engines treat a hyphen as a word boundary, meaning how-to-make-bread is correctly parsed as four separate words. An underscore joins words, so how_to_make_bread may be read as one token. The exception is filenames or code identifiers that live outside public URLs — underscores are conventional there.
Writing good slugs
A good slug is short, descriptive, and stable. Practical guidelines:
- Keep only the meaningful words.
how-to-make-sourdough-breadis better thanhow-to-make-sourdough-bread-at-home-a-beginners-guide-2024. - Drop stop words where they add no meaning. “a”, “an”, “the”, “of” can often be removed without losing clarity. Use judgement — some phrases need them.
- Avoid dates in the slug unless the content is genuinely time-bound. A slug like
best-cameras-2024will read as stale in a year;best-camerasstays evergreen. - Never change a live slug. Once a page is indexed and linked, changing the slug breaks every inbound link and resets the page’s search history. If you must change it, set up a 301 redirect from the old slug to the new one.
When to use the underscore option
Switch to underscore as separator when generating identifiers for code (Python module names, database table names, CSS class names in some systems) rather than web URLs. For anything that will appear in a browser address bar, stay with hyphens.