Example 1 — Official: Lowercase Word
Uppercase only the first letter.
console.log(_.upperFirst("fred"));
// 'Fred' How It Works
- First.
fbecomesF. - Rest.
redstays lowercase. - Result.
Fred. - Docs. Matches the official first example.

Converts the first character of a string to uppercase and leaves everything else unchanged. Part of Lodash String (stable since 4.0.0 — not deprecated). Note: unlike _.capitalize, it does not lowercase the rest of the string.
Pass the string and options shown below. Check the return type before you chain another helper.
Call _.upperFirst. Start with this line.
_.upperFirst([string='']) | Call | What it does |
|---|---|
_.upperFirst([string='']) | Primary signature. |
_.upperFirst(string) | Transform or inspect a string. |
Prefer import upperFirst from "lodash/upperFirst" when you want a smaller bundle.
_.upperFirst([string='']) | Parameter | Description |
|---|---|
| string | Optional. Value to convert (default ''; non-strings are coerced) |
| Return Value | Description |
|---|---|
| * | New string with first character uppercased |
Uppercase only the first letter.
console.log(_.upperFirst("fred"));
// 'Fred' f becomes F.red stays lowercase.Fred.The rest of the string is not forced to lowercase.
console.log(_.upperFirst("FRED"));
// 'FRED' F is already uppercase.RED is left alone.FRED._.capitalizeSame input, different rules for the remaining letters.
var s = "fRED";
console.log(_.upperFirst(s)); // 'FRED'
console.log(_.capitalize(s)); // 'Fred' FRED.Fred._.capitalize._.lowerFirstOpposite helpers for the first character.
console.log(_.upperFirst("fred")); // 'Fred'
console.log(_.lowerFirst("Fred")); // 'fred' _.lowerFirst.Capitalize the first letter without touching later words.
console.log(_.upperFirst("hello WORLD"));
// 'Hello WORLD' h → H.ello WORLD is unchanged._.startCase._.upperFirst is a Lodash String helper available since 4.0.0. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
Available in [email protected] full builds and the lodash/upperFirst modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
Bottom line: Safe for production once Lodash is on the page. Prefer import upperFirst from "lodash/upperFirst" for smaller builds. Native: string.charAt(0).toUpperCase() + string.slice(1).
Split a string into an array of words.
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.
10 people found this page helpful