slugify()
slugify(
input,options?):string
Defined in: utils/string/slugify.ts:61
Convert an arbitrary string into a URL-friendly "slug".
This function:
- Normalizes Unicode (NFKD) and strips diacritics (
é→e). - Keeps only ASCII letters and digits, turning other characters into separators.
- Collapses consecutive separators.
- Optionally truncates the slug and trims trailing separators after truncation when SlugifyOptions.maxLength is provided.
Parameters
input
string
Input string (e.g. a title).
options?
SlugifyOptions = {}
Optional configuration.
Returns
string
Slugified string (may be empty).
Example
ts
slugify('Hello, World!'); // "hello-world"
slugify('Déjà Vu', { lower: false }); // "Deja-Vu"
slugify('A very long title', {
maxLength: 12,
}); // "a-very-long"