What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify · 2 messages · last activity 7/13/2026
The slugify function accepts the following configuration options (all optional):
-
separator — Type:
string, Default:'-'Defines the character used to separate words in the slug. -
lowercase — Type:
boolean, Default:trueControls whether the slug is converted to lowercase. -
decamelize — Type:
boolean, Default:trueConverts camelCase to separate words (e.g.,fooBar→foo bar). -
customReplacements — Type:
Array<string[]>, Default:[['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']]Allows you to define custom character replacements that run before other transformations. -
preserveLeadingUnderscore — Type:
boolean, Default:falsePreserves a leading underscore if the input string starts with one. -
preserveTrailingDash — Type:
boolean, Default:falsePreserves a trailing dash if the input string ends with one. -
preserveCharacters — Type:
string[], Default:[]Allows you to preserve specific characters in the slug (cannot contain the separator). Useful for URLs that need to preserve characters like#. -
transliterate — Type:
boolean, Default:trueControls whether to transliterate characters (convert accented characters and non-Latin scripts to their Latin equivalents). -
locale — Type:
string, Default:undefinedThe locale to use for language-specific transliteration. See the@sindresorhus/transliteratepackage documentation for supported locales.
These defaults and behaviors are implemented in [index.js:L46-L111].
FOLLOW_UPS:
- How does customReplacements interact with transliteration?
- What does decamelize do exactly?
- Can you show a preserveCharacters example?
Want to ask your own question?
Open chat for sindresorhus/slugifyPublic Q&A. Generated by RepoPilot from the actual source of sindresorhus/slugify. AI answers can be incomplete or stale — verify before relying on them.