RepoPilot

What configuration options does the slugify function accept?

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

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options (all optional):

  1. separator — Type: string, Default: '-' Defines the character used to separate words in the slug.

  2. lowercase — Type: boolean, Default: true Controls whether the slug is converted to lowercase.

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

  4. customReplacements — Type: Array<string[]>, Default: [['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']] Allows you to define custom character replacements that run before other transformations.

  5. preserveLeadingUnderscore — Type: boolean, Default: false Preserves a leading underscore if the input string starts with one.

  6. preserveTrailingDash — Type: boolean, Default: false Preserves a trailing dash if the input string ends with one.

  7. 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 #.

  8. transliterate — Type: boolean, Default: true Controls whether to transliterate characters (convert accented characters and non-Latin scripts to their Latin equivalents).

  9. locale — Type: string, Default: undefined The locale to use for language-specific transliteration. See the @sindresorhus/transliterate package 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/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.