Lodash _.capitalize() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

Converts the first character of string to upper case and the remaining characters to lower case. 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 _.capitalize. Start with this line.

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

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

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

Parameters

ParameterDescription
stringOptional. Input to capitalize; default ''

Return Value

Return ValueDescription
*New capitalized string

Lodash Examples

Example 1 — Official FRED

All caps becomes sentence capitalization.

Lodash
_.capitalize("FRED");
// → "Fred"
Try It Yourself

How It Works

  1. Lower. Whole string → fred.
  2. First. Uppercase f → F.
  3. Rest. Stays lower → red.
  4. Docs. Matches the official Lodash example.

Example 2 — Mixed Case Input

Existing capitals in the middle are normalized.

Lodash
_.capitalize("fReD");
// → "Fred"
Try It Yourself

How It Works

  1. Lower first. fReD → fred.
  2. Upper first. → Fred.
  3. Point. Middle capitals do not survive.
  4. Alt. Use upperFirst to keep fReD → FReD.

Example 3 — capitalize vs upperFirst

Same first letter; different treatment of the rest.

Lodash
[
  _.capitalize("fReD"),
  _.upperFirst("fReD")
];
// → ["Fred", "FReD"]
Try It Yourself

How It Works

  1. capitalize. Lowercases all, then uppercases first → Fred.
  2. upperFirst. Only first char → FReD.
  3. Rule. Normalize casing → capitalize; preserve rest → upperFirst.
  4. Source. capitalize is implemented via upperFirst(toLowerCase(...)).

Example 4 — Multi-Word String

Only the first character of the whole string changes style.

Lodash
[
  _.capitalize("hello WORLD"),
  _.startCase("hello WORLD")
];
// → ["Hello world", "Hello World"]
Try It Yourself

How It Works

  1. capitalize. → Hello world (second word lower).
  2. startCase. Capitalizes each word → Hello World.
  3. Use. Titles / names → prefer startCase.
  4. Use. Single-token labels → capitalize is fine.

Example 5 — Empty / Default

Omitted or empty input returns an empty string.

Lodash
[
  _.capitalize(),
  _.capitalize("")
];
// → ["", ""]
Try It Yourself

How It Works

  1. Default. Parameter defaults to ''.
  2. Empty. Nothing to capitalize → "".
  3. Safe. No throw on missing input.
  4. App tip. Guard UI labels if empty should show a fallback.

Browser & Runtime Support

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

✓ Stable · Lodash 3.0.0+

_.capitalize()

Available in [email protected] full builds and the lodash/capitalize 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
_.capitalize Lodash 3.0.0+

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

Frequently Asked Questions

_.capitalize([string='']) converts the first character to upper case and the remaining characters to lower case. Official docs: _.capitalize('FRED') → 'Fred'.
No. capitalize lowercases everything first, then uppercases the first character. Use _.upperFirst() if you only want the first character changed.
capitalize → upperFirst(string.toLowerCase()). upperFirst only touches the first character and leaves the rest unchanged.
No. Only the first character of the whole string. For multi-word titles, use _.startCase().
No. Strings are immutable. _.capitalize always returns a new string.
Use import capitalize from "lodash/capitalize" or require("lodash/capitalize") for tree-shaking.

Next: _.deburr()

Strip accents and diacritics from Unicode text.

_.deburr() 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.

7 people found this page helpful