Dependency-free slugification utilities for frontend and Node.js apps.
- GitHub: https://github.com/Tlouverse/slugify
- Live demo: https://tools.tlouverse.com/slugifier
- npm: https://www.npmjs.com/package/@tlouverse/slugs
npm install @tlouverse/slugsimport { slugify, slugifyLines } from '@tlouverse/slugs';
slugify("John's cafe & bakery");
// "johns-cafe-and-bakery"
slugify('cafe 中文 Привет', { preserveUnicode: true });
// "cafe-中文-привет"
slugify('café 中文 Привет', { transliterate: false, preserveUnicode: true });
// "café-中文-привет"
slugifyLines('First title\nSecond title');
// ["first-title", "second-title"]
slugifyLines(['First title', 'Second title']);
// ["first-title", "second-title"]Returns a single slug string.
Options:
| Option | Default | Description |
|---|---|---|
separator |
'-' |
Separator inserted between slug parts. Supports '-', '_', and '.'. |
lowercase |
true |
Lowercase the result. |
transliterate |
true |
Fold accents and common Latin characters to ASCII, such as é -> e, ß -> ss, and ø -> o. |
preserveUnicode |
false |
Preserve Unicode letters and numbers instead of forcing ASCII-only output. |
wordSubstitutions |
true |
Replace common symbols like &, @, +, %, and # with words. |
maxLength |
0 |
Maximum slug length. 0 means unlimited. |
Accepts either a text block or an array of strings. Text blocks are split on \n, \r\n, or \r; arrays are treated as already-split logical lines.
Additional option:
| Option | Default | Description |
|---|---|---|
preserveEmptyLines |
false |
Keep empty slug lines instead of filtering them out. |
The default output is ASCII-first for broad compatibility with URLs, logs, APIs, filesystems, and older systems. Use preserveUnicode: true when readable native-language slugs are preferred.