In C#, ToLowerInvariant() returns a lowercase copy of a string using the invariant culture. The invariant culture is a fixed set of rules that does not belong to any country, so the result is the same on every computer, whatever its language settings.
Use it for text that a program reads: file extensions, command names, dictionary keys, tags, and protocol words. For text shown to a person in their own language, ToLower() with the current culture can be the better choice.
This is an instance member of System.String. Call it on a string variable, such as text.ToLowerInvariant(...). Calling it on a null variable throws NullReferenceException. C# strings are immutable: ToLowerInvariant() never changes the original text. It gives back a new string (or the same one when there is nothing to change), so keep the result in a variable.
Syntax
No arguments. It is the short form of ToLower(CultureInfo.InvariantCulture).
C#
string code = "Hello WORLD 123";
string key = code.ToLowerInvariant(); // "hello world 123"
Call
What it does
text.ToLowerInvariant()
Lowercase with fixed rules.
switch (cmd.ToLowerInvariant())
Match commands typed in any case.
key.ToLowerInvariant()
Normalize keys before storing them.
It takes no parameters and never depends on CultureInfo.CurrentCulture. It is still a full Unicode lowercase, not only A to Z: letters like É become é. If you only need a comparison, StringComparison.OrdinalIgnoreCase avoids creating a new string at all.
Library declarations
C#
public string ToLowerInvariant();
Parameters
Parameter
Description
None
ToLowerInvariant() takes no parameters.
Return Value
Return Value
Description
string
A new lowercase copy using invariant casing rules.
C# Examples
Example 1 — A Machine-Independent Lowercase
Lowercase a mixed string with letters, spaces, and digits.
C#
using System;
class Program {
static void Main() {
string code = "Hello WORLD 123";
string lower = code.ToLowerInvariant();
Console.WriteLine(lower);
Console.WriteLine(lower.Length == code.Length);
}
}
Output
hello world 123
True
How It Works
All letters lowered. Both the single capital H and the all-caps WORLD become lowercase.
No culture involved. The call does not look at the computer's language settings, so this exact output appears everywhere.
Same length here. For these characters, each letter maps to exactly one letter, so the lengths match.
Digits are ignored.123 has no case and is copied unchanged.
Example 2 — Accept Commands in Any Case
Lowercase each command once, then match it in a switch.
C#
using System;
class Program {
static void Main() {
string[] inputs = { "STOP", "Status", "jump" };
foreach (string input in inputs) {
switch (input.ToLowerInvariant()) {
case "stop":
Console.WriteLine("Stopping");
break;
case "status":
Console.WriteLine("Showing status");
break;
default:
Console.WriteLine("Unknown command: " + input);
break;
}
}
}
}
Output
Stopping
Showing status
Unknown command: jump
How It Works
One spelling in the switch. Each case label is written in lowercase only once.
Lower the input, not the cases.STOP and Status both turn into words that match a label.
Unknown stays unknown.jump matches no label, so the default branch prints it with its original spelling.
Fixed rules matter here. A command list like this must behave identically for every user, which is exactly what the invariant culture guarantees.
Example 3 — ToLowerInvariant and ToLower(InvariantCulture) Are Twins
Show that both spellings give the same text, while the original stays in capitals.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
string title = "TITLE";
string a = title.ToLowerInvariant();
string b = title.ToLower(CultureInfo.InvariantCulture);
Console.WriteLine(a);
Console.WriteLine(a == b);
Console.WriteLine(title);
}
}
Output
title
True
TITLE
How It Works
A risky word.TITLE contains a capital I, the letter that the Turkish culture lowercases to a dotless ı.
Invariant gives i. With fixed rules, the result is always title, on every computer.
Two spellings, one result.ToLower(CultureInfo.InvariantCulture) produces the same text, so the comparison prints True.
Capitals kept.title was never changed; both calls returned new strings.
Frequently Asked Questions
It returns a lowercase copy of the string using the invariant culture, so the result is the same on every computer.
Use ToLowerInvariant for text that code reads or compares: keys, file extensions, commands, and tags. Use ToLower with a culture for text that people read in their language.
Yes. They produce the same result. ToLowerInvariant is simply shorter and needs no System.Globalization import.
No. The closest options are ToLowerInvariant for making a lowercase copy and StringComparison.OrdinalIgnoreCase for comparing without case.
No. It returns a new string and the original stays as it was.