RepoPilot

What configuration options does the slugify function accept?

About sindresorhus/slugify · 2 messages · last activity 5/25/2026

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options in an Options object:

  1. separator (string, default: '-')

    • Specifies the character(s) to use between words in the slug [index.d.ts:L1-L30]
    • Example: slugify('BAR and baz', {separator: '_'}) produces 'bar_and_baz'
  2. lowercase (boolean, default: true)

    • Controls whether the slug is converted to lowercase [index.d.ts:L1-L30]
    • Example: slugify('Déjà Vu!', {lowercase: false}) produces 'Deja-Vu'
  3. decamelize (boolean, default: true)

    • Converts camelCase to separate words (e.g., fooBarfoo bar) [index.js:L51-L80]
    • Example: slugify('fooBar', {decamelize: false}) produces 'foobar'
  4. customReplacements (array of string pairs, default: [['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']])

    • Allows custom character/string replacements applied before other transformations [index.js:L51-L80]
    • Example: slugify('foo@unicorn', {customReplacements: [['@', ' at ']]}) produces 'foo-at-unicorn'
  5. preserveLeadingUnderscore (boolean, default: false)

    • Preserves leading underscores if the string starts with one [index.js:L51-L80]
  6. transliterate (boolean, default: true)

    • Controls whether transliteration is applied (for handling special characters in multiple languages) [index.js:L51-L80]
  7. preserveCharacters (array, default: [])

    • Allows you to specify characters that should not be removed or replaced [index.js:L26-L55]
  8. preserveTrailingDash (boolean, default: false)

    • Preserves trailing dashes if the string ends with one [index.js:L51-L80]

FOLLOW_UPS:

  • How do custom replacements interact with transliteration?
  • What happens with Unicode characters when transliteration is disabled?
  • Can you preserve specific characters from being removed?

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.