What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify · 2 messages · last activity 5/25/2026
Question
RepoPilot
The slugify function accepts the following configuration options in an Options object:
-
separator (string, default:
'-')- Specifies the character(s) to use between words in the slug [index.d.ts:L1-L30]
- Example:
slugify('BAR and baz', {separator: '_'})produces'bar_and_baz'
-
lowercase (boolean, default:
true)- Controls whether the slug is converted to lowercase [index.d.ts:L1-L30]
- Example:
slugify('Déjà Vu!', {lowercase: false})produces'Deja-Vu'
-
decamelize (boolean, default:
true)- Converts camelCase to separate words (e.g.,
fooBar→foo bar) [index.js:L51-L80] - Example:
slugify('fooBar', {decamelize: false})produces'foobar'
- Converts camelCase to separate words (e.g.,
-
customReplacements (array of string pairs, default:
[['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']])- Allows custom character/string replacements applied before other transformations [index.js:L51-L80]
- Example:
slugify('foo@unicorn', {customReplacements: [['@', ' at ']]})produces'foo-at-unicorn'
-
preserveLeadingUnderscore (boolean, default:
false)- Preserves leading underscores if the string starts with one [index.js:L51-L80]
-
transliterate (boolean, default:
true)- Controls whether transliteration is applied (for handling special characters in multiple languages) [index.js:L51-L80]
-
preserveCharacters (array, default:
[])- Allows you to specify characters that should not be removed or replaced [index.js:L26-L55]
-
preserveTrailingDash (boolean, default:
false)- Preserves trailing dashes if the string ends with one [index.js:L51-L80]
FOLLOW_UPS:
- How do custom replacements interact with transliteration?
- What happens with Unicode characters when transliteration is disabled?
- Can you preserve specific characters from being removed?
Want to ask your own question?
Open chat for sindresorhus/slugify →Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/slugify. AI answers can be incomplete or stale — verify before relying on them.