RepoPilot

What configuration options does the slugify function accept?

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

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options:

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

    • Type: string
    • Default: '-'
    • Allows you to customize the character(s) used to separate words in the slug
  2. lowercase [index.d.ts:L26-L40]

    • Type: boolean
    • Default: true
    • Controls whether the slug is converted to lowercase
  3. decamelize [index.d.ts:L51-L62]

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

    • Type: Array<string[]>
    • Default: [['&', ' and '], ['๐Ÿฆ„', ' unicorn '], ['โ™ฅ', ' love ']]
    • Allows you to define custom text replacements that run on the original string before other transformations
  5. preserveLeadingUnderscore

    • Type: boolean
    • Default: false
    • Preserves leading underscores in the slug
  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 include the separator character)

All these options are combined in the Options type definition [index.d.ts:L1-L30].

FOLLOW_UPS:

  • How do custom replacements work internally?
  • What happens with multi-character separators?
  • Does the function support transliteration?

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.