Skip to content

URL Slug Generator

Turn a headline into a clean URL path.

A slug is the human-readable part of a URL that identifies a page — the "url-slug-generator" at the end of this address. Good slugs are lowercase, use hyphens between words, contain no accents or punctuation, and stay short enough to read at a glance in a search result or a shared link.

Producing one by hand is easy to get subtly wrong. Accented characters need transliterating rather than deleting, or "São Paulo" becomes "so-paulo". Punctuation needs collapsing rather than removing, or "Q&A: Part 2" becomes "qa-part-2" with a doubled separator. Trailing separators left by a final exclamation mark look sloppy and sometimes break routing.

This generator handles those cases. Accents are decomposed and stripped so é becomes e and ç becomes c, and the Latin letters that have no accent to strip are transliterated by name: ß becomes ss, ł becomes l, ø becomes o, æ and œ become ae and oe, þ and ð become th and d, and the Turkish dotless ı becomes i. Every run of non-alphanumeric characters collapses into a single separator, and separators at the start and end are trimmed.

Examples

Examples for URL Slug Generator: each row pairs an input with the output it produces.
What it handles Input Output
A page title New York to London Time new-york-to-london-time
Accents and punctuation Café & Croissant!! cafe-croissant
Accents plus a dash São Paulo — Brasil sao-paulo-brasil
Underscore separator Hello World hello_world

How it works

The text is first decomposed into base characters plus combining marks, and the marks are removed — that is what converts é to e without losing the letter. The letters that have no combining-mark form to remove — ß, ø, æ, œ, þ, ð, đ, ł, ħ, ŋ and the Turkish dotless ı among them — are mapped explicitly instead, because decomposition alone would leave them in the URL unchanged. The result is lowercased, then every run of characters that is not a letter or a digit is replaced with the chosen separator. Consecutive separators collapse into one, and leading and trailing separators are trimmed. Letters from non-Latin scripts are kept rather than deleted, so Greek or Cyrillic titles produce a readable slug in their own script rather than an empty string.

When people use it

  • Creating a URL path from an article or product title.
  • Generating consistent identifiers for a CMS or static site.
  • Producing safe filenames from headings.
  • Normalizing imported titles into keys for a database.

Frequently asked questions

Should I use hyphens or underscores?
Hyphens. Search engines treat hyphens as word separators and underscores as joiners, so "new-york" reads as two words while "new_york" can read as one.
How long should a slug be?
Long enough to be clear, short enough to read in a result listing — three to six words is typical. Drop filler words rather than truncating mid-word.
Why are numbers kept?
Numbers are meaningful in titles like "top 10 tools" and are safe in URLs, so they are preserved rather than stripped.
What happens to non-Latin scripts?
Letters are kept as they are. Modern browsers and search engines handle non-Latin URLs, so a Greek or Cyrillic title produces a readable slug rather than nothing.