RepoPilot

What configuration options does the slugify function accept?

About sindresorhus/slugify ยท 2 messages ยท last activity 5/18/2026

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options:

  1. separator (Type: string, Default: '-') - The character(s) to use as a separator between words. [readme.md:L26-L55]

  2. lowercase (Type: boolean, Default: true) - Make the slug lowercase. [readme.md]

  3. decamelize (Type: boolean, Default: true) - Convert camelcase to separate words (e.g., fooBar โ†’ foo bar). [readme.md]

  4. customReplacements (Type: Array<string[]>, Default: [['&', ' and '], ['๐Ÿฆ„', ' unicorn '], ['โ™ฅ', ' love ']]) - Add your own custom character replacements that run on the original string before any other transformations. [readme.md]

  5. preserveLeadingUnderscore (Type: boolean, Default: false) - If your string starts with an underscore, it will be preserved. [readme.md]

  6. preserveTrailingDash (Type: boolean, Default: false) - If your string ends with a dash, it will be preserved. [readme.md:L176-L205]

  7. preserveCharacters (Type: string[], Default: []) - Preserve certain characters (cannot contain the separator). Useful for preserving special characters like # in URLs. [readme.md:L176-L205]

  8. locale (Type: string | undefined, Default: undefined) - The locale to use for language-specific transliteration. [index.d.ts:L151-L180]

  9. transliterate (Type: boolean, Default: true) - Whether to transliterate Unicode characters to ASCII. When false, non-ASCII characters are preserved, which can improve performance. [readme.md:L226-L255]

FOLLOW_UPS:

  • How does customReplacements work with default replacements?
  • What happens when you disable transliteration?
  • How does preserveCharacters interact with separator?

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.