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 7/27/2026
Yes, slugify splits camelCase strings by default. This is controlled by the decamelize option, which defaults to true.
The relevant logic is in [index.js:L85-L87]:
if (options.decamelize) {
string = decamelize(string);
}
According to the documentation in [index.d.ts:L40-L48], the decamelize option works like this:
Convert camelcase to separate words. Internally it does
fooBar→foo bar.
Here's a practical example from [readme.md:L85-L92]:
slugify('fooBar');
//=> 'foo-bar'
slugify('fooBar', {decamelize: false});
//=> 'foobar'
So by default, slugify('fooBar') becomes 'foo-bar', but if you disable decamelization with {decamelize: false}, it produces 'foobar' instead.
FOLLOW_UPS:
- What does the decamelize function do internally?
- Can you show me an example with numbers in camelCase?
- How does decamelize interact with the separator option?
Want to ask your own question?
Open chat for sindresorhus/slugifyPublic Q&A. Generated by RepoPilot from the actual source of sindresorhus/slugify. AI answers can be incomplete or stale — verify before relying on them.