JavaScript String toUpperCase() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

In JavaScript, String.prototype.toUpperCase() returns a new uppercased string using Unicode default case mappings. The original string never changes. Ideal for simple case-insensitive checks paired with toLowerCase().

Remember
str.toUpperCase()     → new UPPERCASE string
original string       → unchanged
no arguments          → none needed
locale rules matter?  → use toLocaleUpperCase()

Syntax

Call toUpperCase on the string you already have. It takes no arguments.

JavaScript
str.toUpperCase()
CallWhat it does
str.toUpperCase()Returns a new string with letters converted to uppercase.
"hi".toUpperCase()Works on string literals too — result is "HI".

Built into JavaScript. Call toUpperCase() on a string — no import needed. For language-specific rules (for example Turkish), prefer toLocaleUpperCase().

Library declarations
JavaScript
str.toUpperCase()

Parameters

This method takes no parameters.

Return Value

Return ValueDescription
stringA new string with characters converted to uppercase.

JavaScript Examples

Example 1 — Basic Uppercase

Convert mixed-case text with Unicode default mappings.

JavaScript
const text = "Hello World";

console.log(text.toUpperCase());
console.log(text);
Try It Yourself

How It Works

  1. Start with text. text holds mixed-case letters.
  2. Call the method. toUpperCase() applies Unicode default mappings.
  3. Original stays put. Strings are immutable, so text is still "Hello World".

Example 2 — Case-Insensitive Compare

Uppercase both sides before checking equality.

JavaScript
const a = "JavaScript";
const b = "JAVASCRIPT";

console.log(a.toUpperCase() === b.toUpperCase());
console.log(a === b);
Try It Yourself

How It Works

  1. Different casing. As written, a and b are not equal.
  2. Normalize both. Call toUpperCase() on each side.
  3. Compare equals. Both become "JAVASCRIPT" → true.

Example 3 — toUpperCase vs toLocaleUpperCase

Default mapping ignores locale; Turkish rules can differ for i.

JavaScript
const letter = "i";

console.log(letter.toUpperCase());
console.log(letter.toLocaleUpperCase("tr"));

console.log("hello".toUpperCase() === "hello".toLocaleUpperCase());
Try It Yourself

How It Works

  1. Default path. toUpperCase() uses Unicode defaults (no locale).
  2. Locale path. toLocaleUpperCase("tr") applies Turkish rules for i → İ.
  3. ASCII is simple. Everyday Latin text often matches on both APIs.

Browser & Runtime Support

String.prototype.toUpperCase() has been available since the earliest JavaScript engines. Safe everywhere.

✓ Baseline · Widely available

String.toUpperCase()

Supported in all modern browsers and Node.js. No polyfill needed for everyday use.

100% Modern browser support
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
toUpperCase() Excellent

Bottom line: Safe for every environment. Prefer toLocaleUpperCase() when language-specific case rules matter.

Frequently Asked Questions

String.prototype.toUpperCase() returns a new string with characters converted to uppercase using Unicode default case mappings. It takes no arguments.
No. Strings are immutable. toUpperCase() returns a new uppercased string; the original stays unchanged.
toUpperCase always uses Unicode default mappings. toLocaleUpperCase can follow language-specific rules (for example Turkish i → İ). Prefer toLocaleUpperCase for user-facing text in a known language.
Normalize both sides: a.toUpperCase() === b.toUpperCase(). For Turkish and similar locales, use toLocaleUpperCase with the same locale on both sides.
Use toLowerCase when you need lowercase text. The APIs are mirrors of each other for default Unicode mappings.

Next: trim()

Learn how to remove whitespace from both ends of a string.

trim() 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