Lodash _.upperFirst() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

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.

Syntax

Call _.upperFirst. Start with this line.

Lodash
_.upperFirst([string=''])
CallWhat 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.

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

Parameters

ParameterDescription
stringOptional. Value to convert (default ''; non-strings are coerced)

Return Value

Return ValueDescription
*New string with first character uppercased

Lodash Examples

Example 1 — Official: Lowercase Word

Uppercase only the first letter.

Lodash
console.log(_.upperFirst("fred"));
// 'Fred'
Try It Yourself

How It Works

  1. First. f becomes F.
  2. Rest. red stays lowercase.
  3. Result. Fred.
  4. Docs. Matches the official first example.

Example 2 — Official: Already Uppercase

The rest of the string is not forced to lowercase.

Lodash
console.log(_.upperFirst("FRED"));
// 'FRED'
Try It Yourself

How It Works

  1. First. F is already uppercase.
  2. Rest. RED is left alone.
  3. Result. Still FRED.
  4. Docs. Matches the official second example.

Example 3 — vs _.capitalize

Same input, different rules for the remaining letters.

Lodash
var s = "fRED";

console.log(_.upperFirst(s)); // 'FRED'
console.log(_.capitalize(s)); // 'Fred'
Try It Yourself

How It Works

  1. upperFirst. Only flips the first character → FRED.
  2. capitalize. First upper + rest lower → Fred.
  3. Pick. Use capitalize for title-style single words.
  4. Next. See _.capitalize.

Example 4 — vs _.lowerFirst

Opposite helpers for the first character.

Lodash
console.log(_.upperFirst("fred")); // 'Fred'
console.log(_.lowerFirst("Fred")); // 'fred'
Try It Yourself

How It Works

  1. upperFirst. Raises the first letter.
  2. lowerFirst. Lowers the first letter.
  3. Rest. Both leave the remaining characters alone.
  4. Next. See _.lowerFirst.

Example 5 — Start a Sentence

Capitalize the first letter without touching later words.

Lodash
console.log(_.upperFirst("hello WORLD"));
// 'Hello WORLD'
Try It Yourself

How It Works

  1. First. h → H.
  2. Rest. ello WORLD is unchanged.
  3. Use. Handy when later casing must stay intact.
  4. Tip. For title case words, try _.startCase.

Browser & Runtime Support

_.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.

✓ Stable · Lodash 4.x

_.upperFirst()

Available in [email protected] full builds and the lodash/upperFirst 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
_.upperFirst Since 4.0.0

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).

Frequently Asked Questions

_.upperFirst([string='']) converts the first character of string to uppercase and leaves the rest unchanged. Official: _.upperFirst('fred') → 'Fred'.
_.upperFirst only uppercases the first character. _.capitalize uppercases the first character and lowercases the rest — so 'FRED' stays 'FRED' with upperFirst, but becomes 'Fred' with capitalize.
_.toUpper uppercases the whole string. _.upperFirst changes only the first character.
No. Strings are immutable. _.upperFirst always returns a new string.
_.upperFirst('') returns ''. Non-strings are coerced to strings first.
Use import upperFirst from "lodash/upperFirst" or require("lodash/upperFirst"). Full build: import _ from "lodash" then _.upperFirst.

Next: _.words()

Split a string into an array of words.

_.words() tutorial →

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.

10 people found this page helpful