RepoPilot

What configuration options does the slugify function accept?

About sindresorhus/slugify · 2 messages · last activity 7/27/2026

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options via an options object [index.js:L46-L58]:

  1. separator (string, default: '-') — The character used to separate words in the slug.

  2. lowercase (boolean, default: true) — Converts the slug to lowercase.

  3. decamelize (boolean, default: true) — Converts camelCase to separate words (e.g., fooBarfoo bar).

  4. customReplacements (Array<string[]>, default: [['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']]) — Custom character/string replacements applied before other transformations.

  5. preserveLeadingUnderscore (boolean, default: false) — Preserves a leading underscore if the input string starts with one.

  6. preserveTrailingDash (boolean, default: false) — Preserves a trailing dash if the input string ends with one [index.d.ts:L121-L130].

  7. preserveCharacters (string[], default: []) — An array of characters to preserve in the output. Cannot include the separator character [index.d.ts:L133-L143].

  8. transliterate (boolean, default: true) — Whether to transliterate Unicode characters to ASCII. When false, non-ASCII characters are preserved instead [index.js:L65-L75].

  9. 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/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.