Does slugify split camelCase strings? Show me the relevant logic.
Does slugify split camelCase strings? Show me the relevant logic.
About sindresorhus/slugify · 2 messages · last activity 6/1/2026
Yes, slugify does split camelCase strings by default through the decamelize option.
According to the documentation in [index.d.ts:L36-L49], the decamelize option converts camelcase to separate words. Internally it transforms fooBar → foo bar.
Here's the example from the README:
slugify('fooBar');
//=> 'foo-bar'
slugify('fooBar', {decamelize: false});
//=> 'foobar'
The option is enabled by default (@default true as shown in [index.d.ts:L37]), so camelCase strings are automatically split into separate words and joined with the separator character.
The test file confirms this behavior with more complex examples in [test.js:L26-L30], including:
slugify('FOOBar')→'foo-bar'slugify('APIs')→'apis'slugify('APISection')→'api-section'
However, the repository data provided doesn't include the actual implementation logic that performs the decamelization. I can search for the specific function if you'd like to see how it's implemented.
FOLLOW_UPS:
- What does the actual decamelize implementation look like?
- How does decamelize interact with custom replacements?
- Are there edge cases with acronyms in camelCase?
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.