What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify ยท 2 messages ยท last activity 7/20/2026
The slugify function accepts the following configuration options via an Options object [index.d.ts:L1-L200]:
-
separator (string, default:
'-')- Character(s) to use between words in the slug [index.d.ts:L1-L16]
-
lowercase (boolean, default:
true)- Makes the slug lowercase [index.d.ts:L18-L33]
-
decamelize (boolean, default:
true)- Converts camelCase to separate words (e.g.,
fooBarโfoo bar) [index.d.ts:L35-L52]
- Converts camelCase to separate words (e.g.,
-
customReplacements (Array<string[]>, default:
[['&', ' and '], ['๐ฆ', ' unicorn '], ['โฅ', ' love ']])- Allows custom character/string replacements that run before other transformations [index.d.ts:L54-L79]
-
preserveLeadingUnderscore (boolean, default:
false)- Preserves a leading underscore if the string starts with one [README excerpt]
-
preserveTrailingDash (boolean, default:
false)- Preserves a trailing dash if the string ends with one [index.d.ts:L121-L135]
-
preserveCharacters (string[], default:
[])- Specifies characters to preserve in the output (cannot contain the separator) [index.d.ts:L137-L155]
-
locale (string, default:
undefined)- Sets the locale for language-specific transliteration [index.d.ts:L157-L172]
-
transliterate (boolean, default:
true)- Controls whether Unicode characters are transliterated to ASCII or preserved [index.d.ts:L174-L200]
The function implementation at [index.js:L46-L111] shows how these options are merged with defaults and applied during the slugification process.
FOLLOW_UPS:
- How are customReplacements applied during slugification?
- What does decamelize transformation do internally?
- How does the locale option affect transliteration?
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.