RepoPilot

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

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

Question

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

RepoPilot

Yes, slugify splits camelCase strings by default. According to the documentation in [readme.md:L76-L88], the decamelize option controls this behavior:

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

Default: true

Here are the examples showing this in action:

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

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

This is also documented in the TypeScript definitions at [index.d.ts:L37-L48]:

readonly decamelize?: boolean;

/**
Convert camelcase to separate words. Internally it does `fooBar` → `foo bar`.

@default true

So when decamelize is true (the default), camelCase strings like fooBar are converted to foo-bar with the separator inserted between the words.

FOLLOW_UPS:

  • How does the decamelize implementation work?
  • What other transformations happen after decamelize?
  • Can I disable decamelize for performance?

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.