RepoPilot

What configuration options does the slugify function accept?

About sindresorhus/slugify · 2 messages · last activity 6/8/2026

Question

What configuration options does the slugify function accept?

RepoPilot

Based on the README, the slugify function accepts an optional options object with the following configuration properties:

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

    • Specifies the character(s) used to separate words in the slug
    • Example: slugify('BAR and baz', {separator: '_'})'bar_and_baz'
  2. lowercase (boolean, default: true)

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

    • Converts camelCase to separate words (e.g., fooBarfoo bar)
    • Example: slugify('fooBar', {decamelize: false})'foobar'
  4. customReplacements (Array<string[]>, default: [['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love ']])

    • Allows you to define custom text replacements that run on the original string before other transformations
    • Overrides default replacements if you use the same key
    • Adding leading/trailing spaces to replacements causes them to be separated by dashes
    • Example: slugify('Foo@unicorn', {customReplacements: [['@', 'at']]})'fooatunicorn'
  5. preserveLeadingUnderscore (boolean, default: false)

    • If enabled, preserves a leading underscore if the input string starts with one

FOLLOW_UPS:

  • How does decamelize interact with lowercase option?
  • Can customReplacements be combined with other options?
  • What happens with special characters by default?

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.