Slugify
Convert a string into a URL-friendly slug.
| Category | Strings |
| Author | Pol Gubau |
| Since | 1.0.4 |
| Last Updated | 2025-03-17 |
| Type | Sync |
| Compatibility | Universal |
Example
Input
slugify('Hello World!')Output:
"hello-world"
Input
slugify('Español está bien', { separator: '_' })Output:
"espanol_esta_bien"
Input
slugify('React & Svelte', { lowercase: false })Output:
"React-Svelte"
Return
A URL-friendly slug generated from the input text.
Type: string
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| text | string | null | No | The input text to convert into a slug. |
| options.separator | string | null | No | Character used to separate words in the slug. Default is '-'. |
| options.lowercase | boolean | null | No | Whether to convert the slug to lowercase. Default is true. |
Notes
This function removes diacritics (accents) and replaces non-alphanumeric characters with the specified separator.
Tags
- string
- slug
- format