Java String toLowerCase() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

In Java, toLowerCase(locale) returns a new String in which every character is converted to lowercase using the rules of the given locale. The original string is immutable and stays as it was.

Use it to normalize text before storing or comparing, for example email addresses or command names. For program logic, pass Locale.ROOT (or Locale.ENGLISH) so the result does not depend on the user's language settings.

toLowerCase() is an instance method of java.lang.String, available since JDK 1.0. Call it on a string, as in text.toLowerCase(...); calling it on a null reference throws NullPointerException. Strings are immutable, so it never changes the original: it returns a new String (or the same one when nothing changes). Keep the result.

Syntax

Pass a locale explicitly; the overload without arguments uses the JVM default locale.

java
String key = input.toLowerCase(Locale.ROOT);   // import java.util.Locale
CallWhat it does
"Java".toLowerCase(Locale.ROOT)"java".
"ABC-123".toLowerCase(Locale.ROOT)"abc-123": digits and symbols stay.
"java".toLowerCase(Locale.ROOT)"java", possibly the same object.

The Turkish pitfall: in a Turkish locale, the capital I lowercases to a dotless i (U+0131), not i. Code such as "TITLE".toLowerCase().equals("title") then fails on a machine set to Turkish. Locale.ROOT always maps I to i.

Library declarations
java
public String toLowerCase();
public String toLowerCase(Locale locale);

Parameters

ParameterDescription
localeOptional. The case-mapping rules to use. Without it, Locale.getDefault() is used.

Return Value

Return ValueDescription
StringThe lowercase text. It may be longer than the original for a few special characters.

Java Examples

Example 1 — Convert a Title to Lowercase

Lowercase mixed text and confirm that the original is unchanged.

java
import java.util.Locale;

public class ToLowerCaseBasic {
    public static void main(String[] args) {
        String title = "Hello WORLD 123";
        String lower = title.toLowerCase(Locale.ROOT);

        System.out.println(lower);
        System.out.println(title);
    }
}

How It Works

  1. Letters change, the rest stays. Every capital becomes lowercase; the digits 123 and the spaces are copied as they are.
  2. A locale-neutral result. Locale.ROOT gives the same output on every machine, whatever its language settings.
  3. Immutability in action. title still prints "Hello WORLD 123"; the lowercase text exists only in lower.

Example 2 — Normalize Email Addresses Before Comparing

Users type addresses with random capitals; lowercase both sides before checking.

java
import java.util.Locale;

public class ToLowerCaseEmail {
    public static void main(String[] args) {
        String typed = "[email protected]";
        String stored = "[email protected]";

        System.out.println("equals:           " + typed.equals(stored));
        System.out.println("lowercase equals: " + typed.toLowerCase(Locale.ROOT).equals(stored));
        System.out.println("equalsIgnoreCase: " + typed.equalsIgnoreCase(stored));
    }
}

How It Works

  1. equals is case-sensitive. 'A' and 'a' are different chars, so the raw comparison fails.
  2. Normalize, then compare. Lowercasing the typed address with Locale.ROOT makes it identical to the stored one.
  3. A shortcut for one-off checks. equalsIgnoreCase reaches the same answer without creating a new string; lowercasing is better when you store the normalized key.

Example 3 — Lowercasing Can Change the Length

The capital I with dot above (U+0130) becomes two chars in Locale.ROOT.

java
import java.util.Locale;

public class ToLowerCaseDottedI {
    public static void main(String[] args) {
        String capital = "\u0130";
        String lower = capital.toLowerCase(Locale.ROOT);

        System.out.println("before: " + capital.length() + " char");
        System.out.println("after:  " + lower.length() + " chars");
        System.out.println("first:  " + lower.charAt(0));
        System.out.println("second: U+" + Integer.toHexString(lower.charAt(1)));
    }
}

How It Works

  1. A special Unicode rule. Outside Turkish and Azeri locales, U+0130 lowercases to a plain i followed by a combining dot above.
  2. One char becomes two. The result has length 2, so an index into the original string may not fit the lowercase copy.
  3. Inspect the second char. Integer.toHexString shows the combining dot as 307 (U+0307), keeping the output ASCII.

Frequently Asked Questions

Without a locale, Java uses the default locale of the machine. In Turkish, I lowercases to a dotless i, which breaks comparisons. Locale.ROOT gives the same result everywhere.
No. Strings are immutable. It returns a new lowercase String, so assign the result: s = s.toLowerCase(Locale.ROOT);
For a single comparison, equalsIgnoreCase() is simpler. Use toLowerCase(Locale.ROOT) when you want to store or look up a normalized key.
Yes, rarely. For example U+0130 becomes two chars in Locale.ROOT. Do not reuse indexes across the conversion.
For case mapping both use the language-neutral rules, so I becomes i. Locale.ROOT expresses "no particular language" most clearly.

Next: toString()

Return the string itself (the same object).

toString() tutorial →

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