Skip to content

slugify

function slugify(input, options?): string;

Defined in: text.ts:156

Turns text into a URL slug: lower-case words joined by -.

Urdu letters are kept as they are (no transliteration: Urdu does not write short vowels, so there is no single Roman spelling). Diacritics, tatweel and zero-width characters are dropped, the Arabic look-alikes ك ي ى become the Urdu ک ی ی, Urdu and Arabic-Indic digits become 0-9, and accented Latin-1 letters lose their accents (é → e, ß → ss). Anything else separates words.

Parameter Type
input string
options? SlugifyOptions

string

The slug, or '' when nothing is left (or the input is not a string). Never throws.

slugify('Lahore Fort, 2024'); // "lahore-fort-2024"
slugify('لاہور قلعہ'); // "لاہور-قلعہ"
slugify('لاہور Fort', { script: 'latin' }); // "fort"
slugify('کراچی ۲۰۲۴', { script: 'urdu' }); // "کراچی-2024"