RepoPilot

Does slugify split camelCase strings? Show me the relevant logic.

About sindresorhus/slugify · 2 messages · last activity 7/13/2026

Question

Does slugify split camelCase strings? Show me the relevant logic.

RepoPilot

Yes, slugify splits camelCase strings by default. This is controlled by the decamelize option, which defaults to true.

Here's the relevant logic:

In [index.js:L56-L58], the function applies decamelization:

if (options.decamelize) {
	string = decamelize(string);
}

The decamelize option is documented in [index.d.ts:L40] and the README shows it converts fooBarfoo bar internally, then converts it to foo-bar with the default separator.

From the README examples [readme.md:L82-L88]:

slugify('fooBar');
//=> 'foo-bar'

slugify('fooBar', {decamelize: false});
//=> 'foobar'

When decamelize is true (the default), camelCase words are separated. When set to false, the camelCase string is treated as a single word and becomes foobar.

FOLLOW_UPS:

  • What other transformations does slugify apply?
  • How are custom character replacements handled?
  • Can I disable multiple transformations at once?

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.