RepoPilot

What configuration options does the slugify function accept?

About sindresorhus/slugify ยท 2 messages ยท last activity 7/6/2026

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options (defined in [index.d.ts:L1-L80]):

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

    • Customizes the character used to separate words in the slug
  2. lowercase (boolean, default: true)

    • Controls whether the output is converted to lowercase
  3. decamelize (boolean, default: true)

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

    • Allows you to define custom character/string replacements applied before other transformations
    • Overrides default replacements if you provide the same key
  5. preserveLeadingUnderscore (boolean, default: false)

    • Preserves leading underscores in the slug (useful for hidden filenames)
  6. preserveTrailingDash (boolean, default: false)

    • Preserves trailing dashes (useful for form validation)
  7. preserveCharacters (string[], default: [])

    • Specifies characters to preserve in the output (cannot contain the separator)
  8. transliterate (boolean, default: true)

    • Controls whether Unicode characters are transliterated to ASCII
  9. locale (string, default: undefined)

    • Sets the locale for language-specific transliteration

The implementation merges these options with defaults in [index.js:L57-L66].

FOLLOW_UPS:

  • How does customReplacements interact with transliterate?
  • What happens with preserveCharacters when separator is empty?
  • Does locale affect the decamelize behavior?

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.