Lodash _.upperCase() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

Converts a string to uppercase words separated by spaces. Separators and camelCase breaks become word boundaries; the result is readable uppercase phrases. Part of Lodash String (stable since 4.0.0 — not deprecated). Note: not the same as _.toUpper, which keeps original separators.

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

Syntax

Call _.upperCase. Start with this line.

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

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

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

Parameters

ParameterDescription
stringOptional. Value to convert (default '')

Return Value

Return ValueDescription
*Uppercase words separated by spaces

Lodash Examples

Example 1 — Official: Hyphenated String

Hyphens become spaces; words go uppercase.

Lodash
console.log(_.upperCase("--foo-bar"));
// 'FOO BAR'
Try It Yourself

How It Works

  1. Split. -- and - mark word edges.
  2. Words. Lodash finds foo and bar.
  3. Upper. Each word becomes uppercase.
  4. Docs. Matches the official first example.

Example 2 — Official: camelCase

A capital letter starts a new word.

Lodash
console.log(_.upperCase("fooBar"));
// 'FOO BAR'
Try It Yourself

How It Works

  1. Break. B in fooBar starts a second word.
  2. Words. foo and Bar.
  3. Result. FOO BAR.
  4. Docs. Matches the official second example.

Example 3 — Official: Underscored String

Underscores are treated as separators too.

Lodash
console.log(_.upperCase("__foo_bar__"));
// 'FOO BAR'
Try It Yourself

How It Works

  1. Strip. Edge underscores are ignored as separators.
  2. Words. foo and bar remain.
  3. Join. Space-separated uppercase words.
  4. Docs. Matches the official third example.

Example 4 — vs _.toUpper

Same input, different separator behavior.

Lodash
var s = "--foo-bar--";

console.log(_.upperCase(s)); // 'FOO BAR'
console.log(_.toUpper(s));   // '--FOO-BAR--'
Try It Yourself

How It Works

  1. upperCase. Words + spaces; separators drop out.
  2. toUpper. Letters rise; hyphens stay.
  3. Pick. Labels/phrases → upperCase; codes → toUpper.
  4. Next. See _.toUpper.

Example 5 — Format a Display Label

Turn an identifier into a readable uppercase label.

Lodash
var key = "userStatus";

console.log(_.upperCase(key));
// 'USER STATUS'
Try It Yourself

How It Works

  1. Input. camelCase property name.
  2. Split. Words become user and Status.
  3. Upper. Result is a spaced label.
  4. Tip. Prefer _.startCase for Title Case labels.

Browser & Runtime Support

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

_.upperCase()

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

Bottom line: Safe for production once Lodash is on the page. Prefer import upperCase from "lodash/upperCase" for smaller builds. Native toUpperCase alone does not split words.

Frequently Asked Questions

_.upperCase([string='']) converts a string to uppercase words separated by spaces. Official: _.upperCase('--foo-bar') → 'FOO BAR'.
_.toUpper uppercases the whole string and keeps separators (e.g. '--FOO-BAR--'). _.upperCase splits into words and joins them with spaces ('FOO BAR').
_.upperFirst only uppercases the first character. _.upperCase uppercases every word and inserts spaces between words.
No. Strings are immutable. _.upperCase always returns a new string.
Lodash word-splits them first. Official: _.upperCase('fooBar') and _.upperCase('__foo_bar__') both become 'FOO BAR'.
Use import upperCase from "lodash/upperCase" or require("lodash/upperCase"). Full build: import _ from "lodash" then _.upperCase.

Next: _.upperFirst()

Uppercase only the first character of a string.

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