Case Sensitivity vs Case Insensitivity
February 1st, 2023 | 3 mins read
Amongst many terms in programming languages or tech in general, there are two that you'd hear and see a lot: case-sensitive and case-insensitive. What do these terms mean?
Let's start by looking at the first word: "case"
case here refers to letter casing which includes uppercase (A) and lowercase (a). Cases make up different words, and you'd find a mix of cases in characters like Abc, AbC, aBc, and so on.
Next, let's look at the word "sensitive".
When something is sensitive, it could be something confidential or with protection. You can say it has restrictions.
How do you apply this to cases in programming?
When you apply the term "case-sensitive" to a string (which could consist of one or more characters), it means that such string can ONLY be equal to another string with the same characters if each character in the first string is respectively in the SAME CASE with each character in the second string.
Let's see some examples:
ais EQUAL to
Xis NOT EQUAL to
x("X" different from "x")
Be Zis EQUAL to
bAMis NOT EQUAL to
bAm("M" different from "m")
programming languageis NOT EQUAL to
programming language("L" different from "l")
Case-sensitive involves a strict check such that for both strings to be the same, it has to be equal, not just in the characters involved, but the casing of each character.
When you apply the term "case-insensitive" to a string, it means that such string can be equal to another string with the same characters without each character having to be in the same case.
In the examples we used above, all strings will be equal since they have the same characters:
ais EQUAL to
Xis EQUAL to
Be Zis EQUAL to
bAMis EQUAL to
programming languageis EQUAL to
Here, there's no strict check on the cases. As long as the characters are the same in both strings, they are equal.
Programming languages work differently when it comes to the quality of cases.
For example, one language could allow you to use commands in any case you want. Say, such language has a
delete command which is used as
delete x. Since there's no case-sensitivity in such language, you could use a command like
deLEte x or
DEletE x and it will execute the operation as expected.
But another language may be strict on cases. So looking at the same
delete command example, if you attempt an operation with
DEletE x, you may get an error where the language tells you "I don't know what
So, it's important to understand what is allowed in programming languages and what isn't.
You can also check this nice discussion on StackOverflow: Should URLs be case-sensitive?
Though programming languages and platforms can have different rules for cases, there are common areas where they apply case-sensitivity.
One example is in comparing user passwords. Such operations require strict checks. If a user registers with "abCde" as their password, during login, a password like "abcde" should not work.
Another example is in unique
ids. It could be an
id for a user, a product, or any object. Because it's unique, strict checks must be put in place.
Other examples fall here; the key point is that such data should be unique, hence, strictly checked
Now you know what these terms mean. If you're learning a new programming language or using a new tool and you hear any of these terms, I hope this article has helped in explaining that.