RepoPilot

What configuration options does the slugify function accept?

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

Question

What configuration options does the slugify function accept?

RepoPilot

The slugify function accepts the following configuration options via an Options object [index.d.ts:L1-L200]:

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

    • Character(s) to use between words in the slug [index.d.ts:L1-L16]
  2. lowercase (boolean, default: true)

    • Makes the slug lowercase [index.d.ts:L18-L33]
  3. decamelize (boolean, default: true)

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

    • Allows custom character/string replacements that run before other transformations [index.d.ts:L54-L79]
  5. preserveLeadingUnderscore (boolean, default: false)

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

    • Preserves a trailing dash if the string ends with one [index.d.ts:L121-L135]
  7. preserveCharacters (string[], default: [])

    • Specifies characters to preserve in the output (cannot contain the separator) [index.d.ts:L137-L155]
  8. locale (string, default: undefined)

    • Sets the locale for language-specific transliteration [index.d.ts:L157-L172]
  9. transliterate (boolean, default: true)

    • Controls whether Unicode characters are transliterated to ASCII or preserved [index.d.ts:L174-L200]

The function implementation at [index.js:L46-L111] shows how these options are merged with defaults and applied during the slugification process.

FOLLOW_UPS:

  • How are customReplacements applied during slugification?
  • What does decamelize transformation do internally?
  • How does the locale option affect 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.