Example 1 — Official FRED
All caps becomes sentence capitalization.
_.capitalize("FRED");
// → "Fred" How It Works
- Lower. Whole string →
fred. - First. Uppercase
f→F. - Rest. Stays lower →
red. - Docs. Matches the official Lodash example.

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.
Call _.capitalize. Start with this line.
_.capitalize([string='']) | Call | What 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.
_.capitalize([string='']) | Parameter | Description |
|---|---|
| string | Optional. Input to capitalize; default '' |
| Return Value | Description |
|---|---|
| * | New capitalized string |
FREDAll caps becomes sentence capitalization.
_.capitalize("FRED");
// → "Fred" fred.f → F.red.Existing capitals in the middle are normalized.
_.capitalize("fReD");
// → "Fred" fReD → fred.Fred.upperFirst to keep fReD → FReD.capitalize vs upperFirstSame first letter; different treatment of the rest.
[
_.capitalize("fReD"),
_.upperFirst("fReD")
];
// → ["Fred", "FReD"] Fred.FReD.capitalize; preserve rest → upperFirst.capitalize is implemented via upperFirst(toLowerCase(...)).Only the first character of the whole string changes style.
[
_.capitalize("hello WORLD"),
_.startCase("hello WORLD")
];
// → ["Hello world", "Hello World"] Hello world (second word lower).Hello World.startCase.capitalize is fine.Omitted or empty input returns an empty string.
[
_.capitalize(),
_.capitalize("")
];
// → ["", ""] ''.""._.capitalize is a Lodash String helper (since 3.0.0). It needs no special browser APIs beyond loading Lodash.
Available in [email protected] full builds and the lodash/capitalize modular import. Works in evergreen browsers and Node / Bun / Deno when Lodash is installed.
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import capitalize from "lodash/capitalize" for smaller builds.
Strip accents and diacritics from Unicode text.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
7 people found this page helpful