Lodash _.kebabCase() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

Converts a string to kebab-case: lowercase words joined by hyphens (foo-bar). Same word-splitting family as _.camelCase and _.snakeCase — only the join style differs. Part of Lodash String (stable — not deprecated).

Pass the string and options shown below. Check the return type before you chain another helper.

Syntax

Call _.kebabCase. Start with this line.

Lodash
_.kebabCase([string=''])
CallWhat it does
_.kebabCase([string=''])Primary signature.
_.kebabCase(string)Transform or inspect a string.

Prefer import kebabCase from "lodash/kebabCase" when you want a smaller bundle.

Library declarations
Lodash
_.kebabCase([string=''])

Parameters

ParameterDescription
stringOptional. Input to convert

Return Value

Return ValueDescription
*Kebab-cased string

Lodash Examples

Example 1 — Official: Foo Bar

Spaces become hyphens; letters go lowercase.

Lodash
_.kebabCase('Foo Bar');
// → 'foo-bar'
Try It Yourself

How It Works

  1. Split. Space separates Foo and Bar.
  2. Lower. Each word becomes lowercase.
  3. Join. Words are joined with -.
  4. Official. Same as the Lodash docs.

Example 2 — camelCase input

Case boundaries become hyphens.

Lodash
_.kebabCase('fooBar');
// → 'foo-bar'

_.kebabCase('HeaderComponent');
// → 'header-component'
Try It Yourself

How It Works

  1. Detect. Capital letters start new words.
  2. fooBar. → foo + bar.
  3. HeaderComponent. → three lowercase parts joined.
  4. Use. Great for CSS class names from JS identifiers.

Example 3 — Official: __FOO_BAR__

Underscores and extra separators are cleaned up.

Lodash
_.kebabCase('__FOO_BAR__');
// → 'foo-bar'
Try It Yourself

How It Works

  1. Strip. Leading/trailing _ are separators.
  2. Split. Middle _ splits FOO / BAR.
  3. Lower + join. → foo-bar.
  4. Official. Third docs example.

Example 4 — URL slug from a title

Turn a page title into a path segment.

Lodash
var title = 'Lodash String Methods!';

'/docs/' + _.kebabCase(title);
// → '/docs/lodash-string-methods'
Try It Yourself

How It Works

  1. Words. Title splits on spaces and punctuation.
  2. ! Dropped as a separator, not kept.
  3. kebab. Lowercase hyphenated slug.
  4. Path. Prefix with your route as needed.

Example 5 — vs snake / camel / lower

Same words, different joins.

Lodash
var s = 'Foo Bar';

_.kebabCase(s);   // → 'foo-bar'
_.snakeCase(s);   // → 'foo_bar'
_.camelCase(s);   // → 'fooBar'
_.lowerCase(s);   // → 'foo bar'
Try It Yourself

How It Works

  1. Same split. All start from the same word list.
  2. Join. -, _, camel, or spaces.
  3. Pick. URLs/CSS → kebab; DB keys → snake; JS → camel.
  4. See. Sibling case helpers linked below.

Browser & Runtime Support

_.kebabCase is a Lodash 4.x String helper. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash or lodash/kebabCase. There is no native kebabCase; DIY would split words and join with -.

✓ Stable · Lodash 4.x

_.kebabCase()

Available in [email protected] and lodash/kebabCase modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.kebabCase Lodash 4.x

Bottom line: Safe for production. Ideal for URL slugs and CSS class names from mixed input.

Frequently Asked Questions

_.kebabCase([string='']) converts a string to kebab-case: lowercase words joined by hyphens. Official: _.kebabCase('Foo Bar') → 'foo-bar'.
Kebab uses hyphens (foo-bar). Snake uses underscores (foo_bar). Use _.snakeCase() for underscores.
Yes. Spaces, underscores, and most punctuation act as word separators and are not kept in the output.
Yes. It is a common way to turn titles into hyphenated, URL-friendly paths.
It splits on case boundaries, so 'fooBar' → 'foo-bar'.
_.lowerCase joins words with spaces ('foo bar'). _.kebabCase joins with hyphens ('foo-bar').

Next: _.lowerCase()

Convert strings to space-separated lowercase words.

_.lowerCase() →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful