What configuration options does the slugify function accept?
What configuration options does the slugify function accept?
About sindresorhus/slugify · 2 messages · last activity 7/27/2026
The slugify function accepts the following configuration options via an options object [index.js:L46-L58]:
-
separator (string, default:
'-') — The character used to separate words in the slug. -
lowercase (boolean, default:
true) — Converts the slug to lowercase. -
decamelize (boolean, default:
true) — Converts camelCase to separate words (e.g.,fooBar→foo bar). -
customReplacements (Array<string[]>, default:
[['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']]) — Custom character/string replacements applied before other transformations. -
preserveLeadingUnderscore (boolean, default:
false) — Preserves a leading underscore if the input string starts with one. -
preserveTrailingDash (boolean, default:
false) — Preserves a trailing dash if the input string ends with one [index.d.ts:L121-L130]. -
preserveCharacters (string[], default:
[]) — An array of characters to preserve in the output. Cannot include the separator character [index.d.ts:L133-L143]. -
transliterate (boolean, default:
true) — Whether to transliterate Unicode characters to ASCII. Whenfalse, non-ASCII characters are preserved instead [index.js:L65-L75]. -
locale (string, default:
undefined) — The locale for language-specific transliteration, passed to the underlying transliterate function.
FOLLOW_UPS:
- How does the customReplacements option work exactly?
- What happens when transliterate is set to false?
- Can you show an example with preserveCharacters?
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.