There's no single universal way to turn non-Latin text into a URL slug, because there's no single universal romanization standard for most scripts. Cyrillic has GOST and ISO 9 competing with looser consumer transliteration; Japanese has Hepburn romanization; Korean has the government's Revised Romanization (which replaced the older McCune-Reischauer system in 2000); Arabic has ALA-LC and DIN 31635. A slug generator has to pick one convention, and different tools legitimately disagree.
What slugify conversion does
- Converts every letter to lowercase.
- Replaces spaces and punctuation with hyphens.
- Transliterates or strips characters outside basic Latin (like Cyrillic or accented letters).
- Collapses repeated hyphens and trims hyphens from the start and end.
For example, the title "Hello, World! How Are You?" turns into something like hello-world-how-are-you.
Why plain URL encoding isn't enough
Percent-encoding (like %D0%9F%D1%80%D0%B8%D0%B2%D1%96%D1%82 for Cyrillic text) is technically valid in a URL but unreadable to a human and looks untrustworthy in an address bar or when a link is shared. A slug solves the readability problem, not just technical validity.
Why you need this
- Automatically generating a blog post's URL from its title.
- Creating a readable identifier from a product name for an online store.
- Building a filename or CSS class from arbitrary text while avoiding disallowed characters.
Collisions: when different titles produce the same slug
The titles "Hello, World!" and "hello world" both normalize (lowercase, punctuation stripped) into the same slug hello-world, even though the source texts differ. If the slug is used as a unique identifier (in an article's URL, say), this kind of collision needs extra handling — typically by appending a numeric suffix or ID to the duplicate.