What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify ยท 2 messages ยท last activity 7/6/2026
The slugify function accepts the following configuration options (defined in [index.d.ts:L1-L80]):
-
separator (string, default:
'-')- Customizes the character used to separate words in the slug
-
lowercase (boolean, default:
true)- Controls whether the output is converted to lowercase
-
decamelize (boolean, default:
true)- Converts camelCase to separate words (e.g.,
fooBarโfoo bar)
- Converts camelCase to separate words (e.g.,
-
customReplacements (Array<string[]>, default:
[['&', ' and '], ['๐ฆ', ' unicorn '], ['โฅ', ' love ']])- Allows you to define custom character/string replacements applied before other transformations
- Overrides default replacements if you provide the same key
-
preserveLeadingUnderscore (boolean, default:
false)- Preserves leading underscores in the slug (useful for hidden filenames)
-
preserveTrailingDash (boolean, default:
false)- Preserves trailing dashes (useful for form validation)
-
preserveCharacters (string[], default:
[])- Specifies characters to preserve in the output (cannot contain the separator)
-
transliterate (boolean, default:
true)- Controls whether Unicode characters are transliterated to ASCII
-
locale (string, default:
undefined)- Sets the locale for language-specific transliteration
The implementation merges these options with defaults in [index.js:L57-L66].
FOLLOW_UPS:
- How does customReplacements interact with transliterate?
- What happens with preserveCharacters when separator is empty?
- Does locale affect the decamelize behavior?
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.