RepoPilot

What configuration options does the slugify function accept?

About sindresorhus/slugify ยท 2 messages ยท last activity 6/1/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) used to separate words in the slug [readme.md:L51-L80]
  2. lowercase (boolean, default: true)

    • Controls whether the slug is converted to lowercase [readme.md:L51-L80]
  3. decamelize (boolean, default: true)

    • Converts camelCase to separate words (e.g., fooBar โ†’ foo bar) [readme.md]
  4. customReplacements (Array<string[]>, default: [['&', ' and '], ['๐Ÿฆ„', ' unicorn '], ['โ™ฅ', ' love ']])

    • Allows you to define custom character replacements that run before other transformations [readme.md]
  5. preserveLeadingUnderscore (boolean, default: false)

    • Preserves a leading underscore if the string starts with one [readme.md]
  6. preserveTrailingDash (boolean, default: false)

    • Preserves a trailing dash if the string ends with one [index.js:L51-L80]
  7. preserveCharacters (array, default: [])

    • Allows you to preserve specific characters that would normally be removed [test.js:L201-L230]
  8. transliterate (boolean, default: true)

    • Controls whether Unicode characters are transliterated to ASCII; when false, non-ASCII characters are preserved [readme.md:L226-L255]
  9. locale (string)

    • Specifies a locale for locale-specific transliteration behavior [test.js:L226-L255]

These options are merged with defaults in [index.js:L51-L80].

FOLLOW_UPS:

  • What do custom replacements do exactly?
  • How does the decamelize option work?
  • What's the difference between transliterate true and false?

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.