RepoPilot

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

About sindresorhus/slugify · 2 messages · last activity 6/29/2026

Question

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

RepoPilot

Yes, slugify does split camelCase strings by default. According to the README, the decamelize option controls this behavior:

Convert camelcase to separate words. Internally it does fooBarfoo bar.

[readme.md:L80-L82]

The default value is true, so camelCase conversion is enabled by default [readme.md:L81]. Here's an example from the documentation:

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

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

[readme.md:L85-L89]

When decamelize is true, the function internally converts fooBar to foo bar before applying other transformations like lowercasing and joining with the separator character.

However, the repository data provided doesn't include the actual implementation code showing the decamelize logic itself—only the API documentation describing how the option works. To see the specific regex or algorithm used to detect and split camelCase, I would need to search the codebase.

FOLLOW_UPS:

  • How is camelCase splitting implemented internally?
  • What separates words when decamelize is enabled?
  • Does decamelize handle consecutive capitals like "XMLParser"?

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.