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/20/2026
Yes, slugify does split camelCase strings by default. This behavior is controlled by the decamelize option, which is true by default.
According to the README, the decamelize option [readme.md:L84-L88] converts camelcase to separate words. Internally it does fooBar → foo bar.
Here are examples from the test suite [test.js:L36-L75]:
slugify('fooBar');
//=> 'foo-bar'
slugify('fooBar', {decamelize: false});
//=> 'foobar'
You can disable this behavior by setting {decamelize: false} in the options.
The TypeScript definitions also document this [index.d.ts:L40], confirming it's a configurable boolean option with a default of true.
FOLLOW_UPS:
- How does the camelCase splitting actually work internally?
- What other text transformations does slugify apply?
- Can you preserve leading underscores in slugified strings?
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.