RepoPilot

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

About sindresorhus/slugify · 2 messages · last activity 5/25/2026

Question

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

RepoPilot

Yes, slugify splits camelCase strings by default. According to the documentation, the decamelize option (default: true) converts camelcase to separate words, internally transforming fooBarfoo bar.

Here's the relevant documentation from the TypeScript definitions:

Convert camelcase to separate words. Internally it does fooBarfoo bar. [index.d.ts:L29-L41]

And the usage example:

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

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

This example shows that with decamelize: true (the default), the camelCase string 'fooBar' is split into separate words and joined with the separator (defaulting to '-'), resulting in 'foo-bar'. Setting {decamelize: false} disables this behavior, producing 'foobar' instead. [index.d.ts:L33-L41]

Unfortunately, the repository data doesn't include the actual implementation code that performs the camelCase splitting. To see the specific logic that executes this transformation, I would need to search the source files.

FOLLOW_UPS:

  • What's the implementation of the decamelize transformation?
  • Can you show the main slugify function implementation?
  • How are custom replacements applied in the process?

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.