What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify ยท 2 messages ยท last activity 6/1/2026
The slugify function accepts the following configuration options in an options object:
-
separator (string, default:
'-')- Specifies the character(s) used to separate words in the slug [readme.md:L51-L80]
-
lowercase (boolean, default:
true)- Controls whether the slug is converted to lowercase [readme.md:L51-L80]
-
decamelize (boolean, default:
true)- Converts camelCase to separate words (e.g.,
fooBarโfoo bar) [readme.md]
- Converts camelCase to separate words (e.g.,
-
customReplacements (Array<string[]>, default:
[['&', ' and '], ['๐ฆ', ' unicorn '], ['โฅ', ' love ']])- Allows you to define custom character replacements that run before other transformations [readme.md]
-
preserveLeadingUnderscore (boolean, default:
false)- Preserves a leading underscore if the string starts with one [readme.md]
-
preserveTrailingDash (boolean, default:
false)- Preserves a trailing dash if the string ends with one [index.js:L51-L80]
-
preserveCharacters (array, default:
[])- Allows you to preserve specific characters that would normally be removed [test.js:L201-L230]
-
transliterate (boolean, default:
true)- Controls whether Unicode characters are transliterated to ASCII; when
false, non-ASCII characters are preserved [readme.md:L226-L255]
- Controls whether Unicode characters are transliterated to ASCII; when
-
locale (string)
- Specifies a locale for locale-specific transliteration behavior [test.js:L226-L255]
These options are merged with defaults in [index.js:L51-L80].
FOLLOW_UPS:
- What do custom replacements do exactly?
- How does the decamelize option work?
- What's the difference between transliterate true and false?
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.