What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify ยท 2 messages ยท last activity 5/18/2026
The slugify function accepts the following configuration options:
-
separator (Type:
string, Default:'-') - The character(s) to use as a separator between words. [readme.md:L26-L55] -
lowercase (Type:
boolean, Default:true) - Make the slug lowercase. [readme.md] -
decamelize (Type:
boolean, Default:true) - Convert camelcase to separate words (e.g.,fooBarโfoo bar). [readme.md] -
customReplacements (Type:
Array<string[]>, Default:[['&', ' and '], ['๐ฆ', ' unicorn '], ['โฅ', ' love ']]) - Add your own custom character replacements that run on the original string before any other transformations. [readme.md] -
preserveLeadingUnderscore (Type:
boolean, Default:false) - If your string starts with an underscore, it will be preserved. [readme.md] -
preserveTrailingDash (Type:
boolean, Default:false) - If your string ends with a dash, it will be preserved. [readme.md:L176-L205] -
preserveCharacters (Type:
string[], Default:[]) - Preserve certain characters (cannot contain the separator). Useful for preserving special characters like#in URLs. [readme.md:L176-L205] -
locale (Type:
string | undefined, Default:undefined) - The locale to use for language-specific transliteration. [index.d.ts:L151-L180] -
transliterate (Type:
boolean, Default:true) - Whether to transliterate Unicode characters to ASCII. Whenfalse, non-ASCII characters are preserved, which can improve performance. [readme.md:L226-L255]
FOLLOW_UPS:
- How does customReplacements work with default replacements?
- What happens when you disable transliteration?
- How does preserveCharacters interact with separator?
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.