Lowercase

5 snippets across 5 stacks - Bash & Linux, HTML & CSS, JavaScript, Python, SQL

SHBash & Linux

Translate or Delete Characters

SH · Text Processing
Syntax
tr [options] set1 [set2]
Example
echo 'Hello World' | tr 'A-Z' 'a-z'
cat data.csv | tr ',' '\t'
tr -d '\r' < windows_file.txt > unix_file.txt
Output
hello world

Note tr reads only from stdin (it cannot take a filename argument). -d deletes characters in set1. -s squeezes repeated characters. Converting \r is handy for fixing Windows line endings.

HCHTML & CSS

Text Transform

HC · Typography
Syntax
text-transform: uppercase | lowercase | capitalize | none;
Example
.label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

.name {
  text-transform: capitalize;
}

Note When using uppercase, add letter-spacing (0.04em to 0.1em) to improve readability. Keep actual content in normal case in the HTML since text-transform is purely visual and screen readers may spell out uppercase letters.

JSJavaScript

Case Conversion

JS · Strings
Syntax
str.toUpperCase()
str.toLowerCase()
str.toLocaleUpperCase(locale)
Example
const status = "Pending";
console.log(status.toUpperCase());  // "PENDING"
console.log(status.toLowerCase());  // "pending"

// Locale-aware (e.g., Turkish "i" -> "I" with dot)
console.log("istanbul".toLocaleUpperCase("tr"));

Note Always use locale-aware methods when dealing with internationalized text. The Turkish i is a classic bug source.

PYPython

Common String Methods

PY · Strings
Syntax
str.method()
Example
email = "  [email protected]  "
print(email.strip().lower())
print("hello world".title())
print("python".startswith("py"))
print("2026-04-04".replace("-", "/"))
Output
[email protected]
Hello World
True
2026/04/04

Note String methods always return new strings since strings are immutable. Chain methods for compact transformations.

SQLSQL

UPPER / LOWER

SQL · String Functions
Syntax
UPPER(string)
LOWER(string)
Example
SELECT
  UPPER(last_name) AS last_upper,
  LOWER(email) AS email_lower
FROM users;
Output
-- last_upper | email_lower
-- JOHNSON    | [email protected]

Note Useful for case-insensitive comparisons: WHERE LOWER(email) = LOWER('[email protected]'). For better performance on frequent case-insensitive lookups, create a functional index on LOWER(column). PostgreSQL also offers ILIKE.

Frequently asked questions

How do you lowercase?
This task is covered in 5 stacks on this page: Bash & Linux, HTML & CSS, JavaScript, Python, SQL. The "Translate or Delete Characters" snippet in Bash & Linux uses `tr [options] set1 [set2]`.
Which command does the Bash & Linux example use?
The "Translate or Delete Characters" snippet uses `tr [options] set1 [set2]`, from the Text Processing section of the Bash & Linux cheat sheet.
Which stacks cover "lowercase" on this page?
Bash & Linux, HTML & CSS, JavaScript, Python, SQL. Together they hold 5 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Translate or Delete Characters": tr reads only from stdin (it cannot take a filename argument). -d deletes characters in set1. -s squeezes repeated characters. Converting \r is handy for fixing Windows line endings.