Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

JavaScript Dictionary

  1. Home
  2. JavaScript Dictionary
  3. String .toUpperCase() / toLowerCase()

String .toUpperCase() / toLowerCase()

Converts all alphabetic characters in a string to uppercase or lowercase. The original string is not modified.

Syntax

// Converts all alphabetic characters to uppercase.
string.toUpperCase()

// Converts all alphabetic characters to lowercase.
string.toLowerCase()

Methods

MethodDescription
toUpperCase()Returns a new string with all alphabetic characters converted to uppercase.
toLowerCase()Returns a new string with all alphabetic characters converted to lowercase.

Sample Code

var str = "Hello World";

// Converts to uppercase.
console.log(str.toUpperCase()); // Outputs "HELLO WORLD".

// Converts to lowercase.
console.log(str.toLowerCase()); // Outputs "hello world".

// The original string is not modified.
console.log(str); // Outputs "Hello World" unchanged.

// Useful for case-insensitive comparisons.
var input = "JavaScript";
var target = "javascript";
console.log(input.toLowerCase() === target.toLowerCase()); // Outputs "true".

// Non-alphabetic characters such as Japanese and spaces are left as-is.
var mixed = "Hello こんにちは 123";
console.log(mixed.toUpperCase()); // Outputs "HELLO こんにちは 123".

Overview

string.toUpperCase() and string.toLowerCase() are methods that convert the alphabetic characters in a string to uppercase or lowercase. Non-alphabetic characters such as Japanese, digits, and symbols are unaffected and remain unchanged.

The most common use case is case-insensitive string comparison. When searching or matching user input, convert both strings to lowercase before comparing. Because string.indexOf() and string.startsWith() are case-sensitive, these methods are often used together with toLowerCase().

Both methods leave the original string unchanged and return a new string. To use the result, assign it to a variable or use it directly.

Browser Compatibility

Chrome Chrome
49+
Supported in all versions
Firefox Firefox
57+
Supported in all versions
Safari Safari
18+
Supported in all versions
Edge Edge
80+
11 or earlier ×
IE IE
11+
2 or earlier ×
Opera Opera
48+
2 or earlier ×
iOS Safari iOS Safari
18+
Supported in all versions
Android Browser Android Browser
37+
4 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
3 or earlier ×

If you find any errors or copyright issues, please .