Uppercase to Lowercase in JavaScript: Methods and Helpers

November 11, 2026 · 11 min read

Uppercase to Lowercase in JavaScript, Title Case and camelCase

To convert uppercase to lowercase in JavaScript, call toLowerCase() on the string: "HELLO".toLowerCase() returns "hello". Use toUpperCase() for the reverse. Both return a new string and leave the original alone. This page also covers locale traps, case-insensitive comparison, and tested helpers for title case and camelCase.

How Do You Convert a String to Lowercase in JavaScript?

toLowerCase() and toUpperCase() take no arguments. They map every letter to its lowercase or uppercase form and pass digits, spaces and punctuation through untouched. JavaScript strings are immutable, so the method can't change the string in place. You have to keep the return value.

const heading = "Hello World 2026!";

const lower = heading.toLowerCase();
const upper = heading.toUpperCase();

console.log(lower);   // hello world 2026!
console.log(upper);   // HELLO WORLD 2026!
console.log(heading); // Hello World 2026! (unchanged)

The last line is the one that catches people. Calling heading.toLowerCase() on its own line does nothing useful, because nobody stores the result. The MDN reference for toLowerCase says the method returns a new string and doesn't affect the original.

For a whole array, map over it:

const tags = ["README", "Docs", "API"];
console.log(tags.map((tag) => tag.toLowerCase())); // [ 'readme', 'docs', 'api' ]

toUpperCase() is the usual choice for values that are conventionally capitalized, such as country codes. "gb".toUpperCase() returns "GB". Normalize case once, where data enters your program, instead of on every comparison. That keeps stored values consistent and your lookups simple.

How Do You Convert One Uppercase Character to Lowercase?

A single character is just a one-character string, so the same methods work. "Q".toLowerCase() gives "q". To capitalize only the first letter of a word, uppercase the first character and glue the rest back on.

const word = "markdown";
console.log(word.charAt(0).toUpperCase() + word.slice(1)); // Markdown

charAt(0) returns an empty string for an empty input, so this line doesn't throw on "".

Older tutorials convert case through character codes instead. In ASCII, A to Z are codes 65 to 90 and a to z are 97 to 122. The gap is 32, so adding 32 lowercases a capital letter.

function asciiLower(ch) {
  return String.fromCharCode(ch.charCodeAt(0) + 32);
}

console.log(asciiLower("A")); // a
console.log(asciiLower("1")); // Q
console.log(asciiLower("é")); // ĉ

It works for A and turns everything else into garbage. A digit becomes a capital Q, and an accented letter becomes a different accented letter. You could guard the range 65 to 90, but then É stays uppercase. The built-in methods already know the full Unicode case tables, so use them.

Some exercises ask you to swap case, so upper becomes lower and lower becomes upper. Compare each character with its own uppercase form.

const swapCase = (text) =>
  [...text]
    .map((ch) => (ch === ch.toUpperCase() ? ch.toLowerCase() : ch.toUpperCase()))
    .join("");

console.log(swapCase("Hello World")); // hELLO wORLD

Locale Traps When Converting Uppercase to Lowercase in JavaScript

toLowerCase() uses Unicode's default case mapping, which is the same on every machine. toLocaleLowerCase() and toLocaleUpperCase() apply language-specific rules instead. Turkish and Azeri are the famous case: they have a dotted and a dotless I, and each one has its own capital.

console.log("I".toLowerCase());           // i
console.log("I".toLocaleLowerCase("tr")); // ı (dotless i)
console.log("i".toLocaleUpperCase("tr")); // İ (dotted capital I)

const city = "İstanbul";
console.log(city.length);                         // 8
console.log(city.toLowerCase().length);           // 9
console.log(city.toLocaleLowerCase("tr"));        // istanbul
console.log(city.toLocaleLowerCase("tr").length); // 8

Without a locale, the capital İ lowercases to a plain i plus a combining dot above, so the string grows by one code unit. With "tr" it becomes a single i. Both mappings come from the Unicode SpecialCasing.txt data file.

The locale version has a second trap. Per the MDN page for toLocaleLowerCase, it always uses the first locale in the list, and an empty or missing argument means the runtime's default locale. Leave the argument out and your code behaves differently on a Turkish user's machine. Here's what a Turkish locale does to an ordinary English word.

console.log("TITLE".toLocaleLowerCase("tr")); // tıtle

Our rule: use plain toLowerCase() for machine values such as HTTP header names, enum keys, file extensions and URL slugs. Pass an explicit locale only for text people read.

Case mapping can also change a string's length outside Turkish.

console.log("Fußball".toUpperCase());        // FUSSBALL
console.log("Fußball".length);               // 7
console.log("Fußball".toUpperCase().length); // 8
console.log("ΟΔΥΣΣΕΥΣ".toLowerCase());       // οδυσσευς

The default uppercase mapping turns the German sharp s into two letters, SS, which is why Fußball gains a character. Greek sigma lowercases to ς at the end of a word and σ everywhere else, and JavaScript applies that rule for you. Never assume the output is as long as the input, especially before slicing by index.

Comparing Strings Without Caring About Case

Lowercasing both sides works for ASCII identifiers. For text people type, it fails as soon as accents differ, and it builds two throwaway strings on every comparison. localeCompare with a sensitivity option is the better tool.

const a = "Résumé";
const b = "RESUME";

console.log(a.toLowerCase() === b.toLowerCase()); // false
console.log(a.localeCompare(b, undefined, { sensitivity: "base" }) === 0); // true

const caseOnly = new Intl.Collator(undefined, { sensitivity: "accent" });
console.log(caseOnly.compare("Résumé", "RÉSUMÉ") === 0); // true
console.log(caseOnly.compare("Résumé", "resume") === 0); // false

"base" ignores both case and accents. "accent" ignores case but keeps accents, so Résumé and resume stay different. If you compare many strings, create one Intl.Collator and reuse it. The localeCompare reference notes that results depend on the locale: Swedish treats ä as its own letter, not an accented a. Python handles case-insensitive matching with casefold(), covered in our guide to Python string case methods.

The same collator sorts a list without any lowercasing. The default sort() compares UTF-16 code units, so every capitalized word lands before every lowercase one.

const sorter = new Intl.Collator(undefined, { sensitivity: "accent" });
const names = ["banana", "apple", "Cherry"];

console.log([...names].sort());               // [ 'Cherry', 'apple', 'banana' ]
console.log([...names].sort(sorter.compare)); // [ 'apple', 'banana', 'Cherry' ]

The spread copies the array first, because sort() changes the array it's called on.

Title Case in JavaScript: A Function That Skips Small Words

The one-liner most answers give looks fine until real text arrives:

const naiveTitle = (text) => text.replace(/\b\w/g, (ch) => ch.toUpperCase());

console.log(naiveTitle("don't stop"));            // Don'T Stop
console.log(naiveTitle("élan vital"));            // éLan Vital
console.log(naiveTitle("the lord of the rings")); // The Lord Of The Rings

\b\w only understands ASCII word characters. An apostrophe counts as a word boundary, and é doesn't count as a letter at all. It also capitalizes every small word. Here's a JS title case helper that fixes all three.

const SMALL_WORDS = new Set([
  "a", "an", "and", "as", "at", "but", "by", "for", "in",
  "nor", "of", "on", "or", "the", "to", "up", "via",
]);

function capitalize(word) {
  // Uppercase the first letter, skipping quotes or brackets in front of it
  return word.replace(/\p{L}/u, (ch) => ch.toUpperCase());
}

function toTitleCase(text) {
  const words = text.toLowerCase().trim().split(/\s+/);
  const last = words.length - 1;
  return words
    .map((word, i) => {
      if (i > 0 && i < last && SMALL_WORDS.has(word)) return word;
      return word
        .split("-")
        .map((part, j) => (j > 0 && SMALL_WORDS.has(part) ? part : capitalize(part)))
        .join("-");
    })
    .join(" ");
}

console.log(toTitleCase("the lord of the rings"));                // The Lord of the Rings
console.log(toTitleCase("don't stop believing"));                 // Don't Stop Believing
console.log(toTitleCase("élan vital in a state-of-the-art lab")); // Élan Vital in a State-of-the-Art Lab
console.log(toTitleCase("what are you looking at"));              // What Are You Looking At

\p{L} matches any Unicode letter, but only with the u flag (or the newer v flag). The first and last words are always capitalized, which is why the fourth title ends with a capital At. The small-word list is a code choice, so edit it to match your house style. Our title case rules guide shows where AP, APA, Chicago and MLA differ on those words.

The limitation: the helper lowercases first, so toTitleCase("NASA launches a new rocket") returns Nasa Launches a New Rocket. It doesn't know proper nouns, acronyms or capitalization after a colon. A small exceptions map covers the words you always want in a fixed form.

const EXCEPTIONS = new Map([
  ["nasa", "NASA"],
  ["javascript", "JavaScript"],
]);

const titleWithExceptions = (text) =>
  toTitleCase(text)
    .split(" ")
    .map((word) => EXCEPTIONS.get(word.toLowerCase()) ?? word)
    .join(" ");

console.log(titleWithExceptions("NASA picks javascript for a rover")); // NASA Picks JavaScript for a Rover

That's the whole JavaScript title case toolkit: a lowercase pass, a small-word list and an exceptions map. CSS text-transform: capitalize only changes how text looks and capitalizes every word, small ones included.

camelCase in JavaScript: Turning Labels Into Identifiers

You'll reach for this when CSV headers or form labels become object keys. The core of converting a label to camel case in JavaScript is one regex. It finds each run of non-alphanumeric characters and uppercases the character after it. The helper below also splits input that's already camelCase, so userProfileId passes through unchanged.

function toCamelCase(text) {
  return text
    .replace(/(\p{Ll}|\p{N})(\p{Lu})/gu, "$1 $2") // split existing camelCase
    .toLowerCase()
    .replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "") // trim separators
    .replace(/[^\p{L}\p{N}]+(.)/gu, (_, ch) => ch.toUpperCase());
}

console.log(toCamelCase("user profile-id_value"));  // userProfileIdValue
console.log(toCamelCase("  Total amount (USD)  ")); // totalAmountUsd
console.log(toCamelCase("café au lait"));           // caféAuLait
console.log(toCamelCase("userProfileId"));          // userProfileId
console.log(toCamelCase("XMLHttp request"));        // xmlhttpRequest

Acronyms are the weak spot. The split only fires on a lowercase-to-uppercase boundary, so XMLHttp stays one word and comes out as xmlhttp. If your inputs contain acronyms, decide on a style and handle them before calling the helper. Our camel case guide compares the HTTPServer and HttpServer conventions.

PascalCase is the same output with its first letter capitalized. Going back from camelCase to plain words takes a single replace.

const toPascalCase = (text) => capitalize(toCamelCase(text));
console.log(toPascalCase("user profile-id_value")); // UserProfileIdValue

const toWords = (text) => text.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase();
console.log(toWords("userProfileId")); // user profile id

We prefer two small helpers you can read over adding a dependency for them. If you keep them in a README or a gist, wrap them in a fence tagged javascript, as our guide to Markdown code blocks explains.

Handling null, Numbers and Other Non-String Values

toLowerCase() is a string method, so calling it on null or undefined throws a TypeError. In Chrome and Node the message reads "Cannot read properties of null". Other engines word it differently. Numbers don't have the method either, so (42).toLowerCase() throws too.

const toLowerSafe = (value) => (value == null ? "" : String(value).toLowerCase());

console.log(toLowerSafe("README")); // readme
console.log(toLowerSafe(null));     // (empty string)
console.log(toLowerSafe(42));       // 42
console.log(String.prototype.toLowerCase.call(true)); // true

String(value) converts anything to text first. When you only expect strings or nullish values, value?.toLowerCase() ?? "" is shorter. The last line shows that the method converts a non-string this to a string, so true becomes "true".

Lowercasing is also the first step when you build heading IDs while rendering Markdown in JavaScript.

Converting uppercase to lowercase in JavaScript is one method call, but locale, length changes and nullish values decide whether it's correct. Test your helpers with Turkish, German and accented input before you trust them, and copy the title case and camelCase functions above into your utilities. To convert text without writing code, try the case converter, which runs in your browser with 11 styles including title and camel. For notes and docs, open the editor.