Lodash _.camelCase() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

Converts string to camel case (fooBar). Part of Lodash String (since 3.0.0).

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

Syntax

Call _.camelCase. Start with this line.

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

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

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

Parameters

ParameterDescription
stringOptional. Input to convert; default ''

Return Value

Return ValueDescription
*New camelCase string

Lodash Examples

Example 1 — Space-Separated Words

Official docs: title-style text to camelCase.

Lodash
_.camelCase("Foo Bar");
// → "fooBar"
Try It Yourself

How It Works

  1. Split. Space separates Foo and Bar.
  2. First word. Lowercased → foo.
  3. Next words. Capitalized and joined → Bar.
  4. Result. fooBar.

Example 2 — Hyphen / Kebab Input

Extra dashes are ignored as separators.

Lodash
_.camelCase("--foo-bar--");
// → "fooBar"
Try It Yourself

How It Works

  1. Split. Hyphens mark word boundaries.
  2. Cleanup. Leading/trailing dashes do not become words.
  3. Join. foo + Bar → fooBar.
  4. Docs. Matches the second official example.

Example 3 — Underscore / Snake Input

Uppercase snake_case normalizes the same way.

Lodash
_.camelCase("__FOO_BAR__");
// → "fooBar"
Try It Yourself

How It Works

  1. Split. Underscores separate FOO and BAR.
  2. Case. Words are normalized (not left fully upper).
  3. Join. Camel style → fooBar.
  4. Docs. Matches the third official example.

Example 4 — vs kebabCase & snakeCase

Same words; different join characters.

Lodash
var s = "Foo Bar";

[
  _.camelCase(s),
  _.kebabCase(s),
  _.snakeCase(s)
];
// → ["fooBar", "foo-bar", "foo_bar"]
Try It Yourself

How It Works

  1. Split. All three helpers see the same words.
  2. camelCase. No separator → fooBar.
  3. kebabCase. Hyphen join → foo-bar.
  4. snakeCase. Underscore join → foo_bar.

Example 5 — Mixed Separators

Spaces, dashes, and underscores together.

Lodash
_.camelCase("hello-world_test CASE");
// → "helloWorldTestCase"
Try It Yourself

How It Works

  1. Split. -, _, and spaces all act as boundaries.
  2. Words. hello, world, test, CASE.
  3. Normalize. First lower; later words capitalized.
  4. Result. helloWorldTestCase.

Browser & Runtime Support

_.camelCase is a Lodash String helper (since 3.0.0). It needs no special browser APIs beyond loading Lodash.

✓ Stable · Lodash 3.0.0+

_.camelCase()

Available in [email protected] full builds and the lodash/camelCase modular import. Works in evergreen browsers and Node / Bun / Deno when Lodash is installed.

100% With Lodash 3.0.0+
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
_.camelCase Lodash 3.0.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import camelCase from "lodash/camelCase" for smaller builds.

Frequently Asked Questions

_.camelCase([string='']) converts a string to camel case. Official docs: _.camelCase('Foo Bar') → 'fooBar'; _.camelCase('--foo-bar--') → 'fooBar'; _.camelCase('__FOO_BAR__') → 'fooBar'.
No. JavaScript strings are immutable. _.camelCase always returns a new string.
Lodash uses its word-splitting rules (spaces, hyphens, underscores, and case boundaries). The same family of rules powers kebabCase, snakeCase, and startCase.
Same word split; different join. camelCase → fooBar; kebabCase → foo-bar; snakeCase → foo_bar.
Lodash still normalizes via its word rules. Simple camelCase like 'fooBar' typically stays 'fooBar'.
Use import camelCase from "lodash/camelCase" or require("lodash/camelCase") for tree-shaking.

Next: _.capitalize()

Uppercase the first character and leave the rest unchanged.

_.capitalize() tutorial →

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.

8 people found this page helpful