Slugify Libraries Compared: JS, Python, PHP & Ruby
We ran 10 slugify libraries on the same tricky inputs (ß, Ł, Cyrillic, Arabic, apostrophes). Real outputs, the gotchas, and which library to pick.

Every web framework eventually needs to turn "The Ultimate Guide to Café Culture!" into ultimate-guide-cafe-culture. There are dozens of libraries for it, and their READMEs all promise "clean, URL-safe slugs". The interesting part is where they disagree — and you only find that out with awkward input.
So we tested them. Same nine inputs, ten libraries, four languages, real output copied from the terminal. No library authors were consulted; these are the defaults you get after npm install, pip install, composer require or gem install.
The test inputs
Each input targets a specific failure mode we have seen break real sites:
| Input | What it tests |
|---|---|
Straße & Café |
German ß (doesn't decompose under Unicode NFD) and & |
Hello World! |
The baseline — every library should pass |
Привет мир |
Cyrillic script |
Łódź Guide |
Polish Ł (another letter NFD can't fix) |
أفضل نصائح السيو |
Arabic script |
影師嗎 |
Chinese characters |
Don't Stop |
Apostrophe inside a word |
I ♥ Dogs |
Symbol with a meaning |
Größe Über |
German umlauts (ö, ü) |
JavaScript results
Tested: slugify (simov), @sindresorhus/slugify, transliteration and github-slugger.
| Input | slugify {lower, strict} |
@sindresorhus/slugify | transliteration | github-slugger |
|---|---|---|---|---|
| Straße & Café | strasse-and-cafe |
strasse-and-cafe |
strasse-cafe |
straße--café |
| Привет мир | privet-mir |
privet-mir |
privet-mir |
привет-мир |
| Łódź Guide | lodz-guide |
lodz-guide |
lodz-guide |
łódź-guide |
| أفضل نصائح السيو | afdhl-nsaeh-alsyw |
afdl-nsayh-alsyw |
fdl-nsy-h-lsyw |
أفضل-نصائح-السيو |
| 影師嗎 | (empty) | (empty) | ying-shi-ma |
影師嗎 |
| Don't Stop | dont-stop |
dont-stop |
don-t-stop |
dont-stop |
| I ♥ Dogs | i-love-dogs |
i-love-dogs |
i-dogs |
i--dogs |
| Größe Über | grosse-uber |
groesse-ueber |
grosse-uber |
größe-über |
What stands out:
slugifykeeps the original case by default. Without options,slugify('Hello World!')returnsHello-World!— capital letters and the exclamation mark. Always pass{ lower: true, strict: true }. Withlocale: 'de'it producesgroesse-ueberand even turns&intound.@sindresorhus/slugifyhas the best defaults of the group: lowercase, German-style umlauts,&→and,♥→love. It is ESM-only, and shipsslugifyWithCounter(), which returnsfoo-bar,foo-bar-2,foo-bar-3for repeated input.github-sluggeris not a URL slugger. It reproduces GitHub's heading anchors, so it keeps Unicode and can produce double hyphens. Use it for Markdown heading IDs, not page URLs.- Arabic transliteration is lossy everywhere.
afdhl-nsaeh-alsywis not something an Arabic reader would ever search. For Arabic content, a native-script slug is usually the better choice (more on that in URL slugs for non-Latin languages).
Python results
Tested: python-slugify 8.0.4 and Django's slugify (4.2), with and without allow_unicode.
| Input | python-slugify | Django | Django allow_unicode=True |
|---|---|---|---|
| Straße & Café | strasse-cafe |
strae-cafe |
straße-café |
| Привет мир | privet-mir |
(empty) | привет-мир |
| Łódź Guide | lodz-guide |
odz-guide |
łódź-guide |
| أفضل نصائح السيو | fdl-nsyh-lsyw |
(empty) | أفضل-نصائح-السيو |
| 影師嗎 | ying-shi-ma |
(empty) | 影師嗎 |
| Don't Stop | don-t-stop |
dont-stop |
dont-stop |
| Größe Über | grosse-uber |
groe-uber |
größe-über |
What stands out:
- Django's default silently deletes letters.
slugify('Straße')isstraeandslugify('Łódź')isodz. Any Cyrillic, Arabic or Chinese title produces an empty slug — which, if you use the slug as a URL or unique key, is a production bug waiting to happen. Django only promises ASCII by stripping; it does not transliterate. - python-slugify transliterates nearly everything, but splits
don'tintodon-t. Fix that withreplacements=[["'", ""]]. It also supportsmax_lengthwithword_boundary=True,stopwords, and customseparator. - Neither does German umlauts by default (
grosse-uber). In python-slugify, addreplacements=[['ü', 'ue'], ['ö', 'oe'], ['ä', 'ae']].
PHP results
Tested: Laravel's Str::slug (illuminate/support 13), cocur/slugify 4.7 and Symfony's AsciiSlugger (symfony/string 8.1, with the intl extension).
| Input | Laravel Str::slug |
cocur/slugify | Symfony AsciiSlugger |
|---|---|---|---|
| Straße & Café | strasse-cafe |
strasse-cafe |
Strasse-Cafe |
| Привет мир | privet-mir |
privet-mir |
Privet-mir |
| Łódź Guide | lodz-guide |
lodz-guide |
Lodz-Guide |
| 影師嗎 | (empty) | (empty) | ying-shi-ma |
| Don't Stop | dont-stop |
don-t-stop |
Don-t-Stop |
| Größe Über | grosse-uber |
groesse-ueber |
Grosse-Uber |
What stands out:
- Symfony keeps case. Call
->lower()on the result:$slugger->slug($title)->lower(). Passing a locale (new AsciiSlugger('de')) givesgroesse-ueber. - Laravel takes a language argument.
Str::slug('Größe Über', '-', 'de')returnsgroesse-ueber. It also converts@toatby default (hello@example.com→hello-at-examplecom). - cocur/slugify's
rulesetsoption replaces the defaults. Constructing it with['rulesets' => ['default', 'german']]broke Cyrillic (empty output) and turnedŁódźintood-guidein our test. Use$slugify->activateRuleSet('german')on a default instance instead — that kept everything working.
Ruby results
Tested: Rails' String#parameterize (ActiveSupport 8.1) with default I18n settings.
| Input | parameterize |
|---|---|
| Straße & Café | strasse-cafe |
| Привет мир | (empty) |
| Łódź Guide | lodz-guide |
| Don't Stop | don-t-stop |
| Größe Über | grosse-uber |
parameterize transliterates Latin letters well but, like Django, drops Cyrillic completely unless you add transliteration rules to your I18n locale files.
The big picture
| Library | Lowercase by default | Cyrillic | German umlauts (ae/oe/ue) | Apostrophes | Unique-slug helper |
|---|---|---|---|---|---|
| slugify (JS) | No — pass lower |
Yes | With locale: 'de' |
Yes (strict) |
No |
| @sindresorhus/slugify | Yes | Yes | Yes | Yes | Yes |
| python-slugify | Yes | Yes | Via replacements |
Splits | No |
| Django slugify | Yes | Empty | No (deletes ß) | Yes | No |
| Laravel Str::slug | Yes | Yes | With 'de' |
Yes | No |
| cocur/slugify | Yes | Yes | Yes | Splits | No |
| Symfony AsciiSlugger | No — ->lower() |
Yes | With locale | Splits | No |
| Rails parameterize | Yes | Empty | No | Splits | No |
Which one should you use?
- JavaScript/TypeScript (ESM):
@sindresorhus/slugify. Best defaults, and the counter helper solves duplicate slugs. - JavaScript (CommonJS) or tiny bundles:
slugifywith{ lower: true, strict: true }. - Python:
python-slugify. Only use Django's built-in if your titles are guaranteed ASCII, or passallow_unicode=Trueand accept native-script slugs. - PHP / Laravel:
Str::slug($title, '-', $locale)— it is already in your project. For non-Laravel apps,cocur/slugify. - Ruby on Rails:
parameterizefor Latin-script content; add I18n transliteration rules (or a gem) for Cyrillic.
Whatever you choose, test it with your own worst-case titles before trusting it with your URLs. The fastest way to see what a correct slug should look like is to paste the same titles into the Slugme.io generator — it handles every input above, including German-style umlauts and native Arabic — and compare. For a whole list at once, use the bulk slug generator.
Want to build your own instead? See our guides for JavaScript, Python and PHP & Laravel.
Methodology: all outputs were produced on October 25, 2026 with the library versions listed above, default options unless stated, and copied verbatim. Some rows (like "Hello World!", where every library returned hello-world) are omitted from the per-language tables for brevity.
Frequently asked questions
What is the best slugify library for JavaScript?
For ESM projects, @sindresorhus/slugify has the best defaults: lowercase output, German-style umlauts, "&" → "and", and a slugifyWithCounter() helper for unique slugs. For CommonJS or the smallest footprint, slugify (by simov) is excellent — just pass { lower: true, strict: true }.
Why does Django's slugify remove some letters?
With allow_unicode=False (the default), Django normalizes to NFKD and drops anything that is not ASCII. Letters that don't decompose into a base letter plus an accent — ß, ł, ø — are deleted, and whole scripts like Cyrillic or Arabic disappear. Use python-slugify if you need transliteration.
Do slugify libraries transliterate Chinese?
Some do. In our test, python-slugify, Symfony's AsciiSlugger and the transliteration npm package converted 影師嗎 to "ying-shi-ma" (pinyin), while slugify, @sindresorhus/slugify, Laravel and cocur returned an empty string.
Should I write my own slugify function?
For a single-language site with simple titles, a 10-line function is fine. As soon as you handle user-generated titles or multiple languages, a maintained library saves you from edge cases — or generate slugs with a dedicated tool and store them.