RepoPilot

What configuration options does the slugify function accept?

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

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts an options object with the following configuration options:

  1. separator [index.d.ts:L1-L15]

    • Type: string
    • Default: '-'
    • Controls the character used to separate words in the slug
  2. lowercase [index.d.ts:L26-L30]

    • Type: boolean
    • Default: true
    • Makes the slug lowercase (or preserves case if set to false)
  3. decamelize [index.d.ts:L33-L42]

    • Type: boolean
    • Default: true
    • Converts camelCase to separate words (e.g., fooBar โ†’ foo bar)
  4. customReplacements [index.d.ts:L51-L71]

    • Type: Array<string[]>
    • Default: [['&', ' and '], ['๐Ÿฆ„', ' unicorn '], ['โ™ฅ', ' love ']]
    • Allows you to define custom character/phrase replacements that run before other transformations
  5. preserveLeadingUnderscore [readme.md, mentioned in the excerpt]

    • Type: boolean
    • Default: false
    • Preserves leading underscores in the string
  6. preserveTrailingDash [readme.md:L176-L205]

    • Type: boolean
    • Default: false
    • Preserves trailing dashes in the slug
  7. preserveCharacters [readme.md:L176-L205]

    • Type: string[]
    • Default: []
    • Allows you to specify characters that should be preserved in the slug (cannot contain the separator)

FOLLOW_UPS:

  • How do customReplacements differ from default replacements?
  • Can you combine multiple options together?
  • 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.