You’re reviewing a pull request. The code works perfectly. The logic is sound. The tests pass.
But something feels… off.
const User_Name = "John";
const user-email = "john@example.com";
const USERADDRESS = "123 Main St";
Your eye twitches. These variable names are technically valid, but they violate every naming convention in the book.
Here’s the truth: inconsistent case conventions are code smell. They signal inexperience, make codebases harder to maintain, and create friction in team collaboration.
But here’s the problem: which case convention should you use? And when?
If you’ve ever wondered whether to use getUserData or get_user_data or get-user-data, this guide is for you.
Let’s explore the world of text case conventions, why they matter, and when to use each one.
Why Case Conventions Matter
Before we dive into specific conventions, let’s address the elephant in the room: Why does this even matter?
After all, computers don’t care if you write myVariable or my_variable or MY_VARIABLE. The code runs the same.
But humans care. And code is written once but read dozens (or hundreds) of times.
The Real Cost of Bad Naming
Poor case conventions create:
- Cognitive friction - Developers waste mental energy parsing inconsistent names
- Merge conflicts - Different team members use different conventions
- Bugs - Case-sensitive languages treat
userNameandUserNameas different variables - Slower onboarding - New developers struggle to understand the codebase patterns
- Professional perception - Sloppy naming suggests sloppy thinking
Good case conventions, on the other hand, make code self-documenting and teams more productive.
The Major Case Conventions Explained
Let’s break down each major case style, its origins, and its primary uses.
1. camelCase (Lower Camel Case)
Pattern: First word lowercase, subsequent words capitalized, no separators
Examples: userName, getUserData, isActive, totalPrice
Where it’s used:
- JavaScript/TypeScript - Variables, functions, object properties
- Java - Variables, methods, instance fields
- C# - Variables, parameters, private fields
- Swift - Variables, functions, parameters
Why it works: Compact, readable, and the standard in most object-oriented languages.
Convert text to camelCase: Use our camelCase Converter
Real-World Example
// Good - Consistent camelCase
const userProfile = {
firstName: "Jane",
lastName: "Doe",
emailAddress: "jane@example.com",
isVerified: true,
};
function getUserFullName(user) {
return `${user.firstName} ${user.lastName}`;
}
2. PascalCase (Upper Camel Case)
Pattern: Every word capitalized, including the first, no separators
Examples: UserName, GetUserData, IsActive, TotalPrice
Where it’s used:
- C# - Classes, interfaces, public methods, properties
- Java - Classes, interfaces, enums
- TypeScript - Classes, interfaces, type definitions
- Swift - Types, protocols, enums
- Pascal - Everything (hence the name)
Why it works: Immediately distinguishes types from values, making code structure clear.
Convert text to PascalCase: Use our PascalCase Converter
Real-World Example
// Good - PascalCase for types, camelCase for instances
class UserProfile {
firstName: string;
lastName: string;
constructor(firstName: string, lastName: string) {
this.firstName = firstName;
this.lastName = lastName;
}
GetFullName(): string {
return `${this.firstName} ${this.lastName}`;
}
}
const userProfile = new UserProfile("Jane", "Doe");
3. snake_case (Lower Snake Case)
Pattern: All lowercase, words separated by underscores
Examples: user_name, get_user_data, is_active, total_price
Where it’s used:
- Python - Variables, functions, module names
- Ruby - Variables, methods, file names
- Rust - Variables, functions, modules
- C - Variables, functions
- SQL - Table names, column names (often)
- File systems - Unix/Linux file naming
Why it works: Highly readable, especially in languages that favor explicitness over brevity.
Convert text to snake_case: Use our snake_case Converter
Real-World Example
# Good - Consistent snake_case in Python
user_profile = {
"first_name": "Jane",
"last_name": "Doe",
"email_address": "jane@example.com",
"is_verified": True
}
def get_user_full_name(user):
return f"{user['first_name']} {user['last_name']}"
4. kebab-case (Spinal Case)
Pattern: All lowercase, words separated by hyphens
Examples: user-name, get-user-data, is-active, total-price
Where it’s used:
- CSS/SCSS - Class names, IDs, custom properties
- HTML - Custom element names, data attributes
- URLs - Path segments, slugs
- File names - Web assets, markdown files
- Command-line flags -
--verbose,--dry-run
Why it works: URL-safe, SEO-friendly, and visually distinct from other conventions.
Convert text to kebab-case: Use our kebab-case Converter
Real-World Example
/* Good - kebab-case in CSS */
.user-profile-card {
background-color: var(--primary-color);
border-radius: var(--border-radius-small);
}
.user-profile-card__header {
font-size: var(--font-size-large);
}
<!-- Good - kebab-case for custom elements -->
<user-profile-card data-user-id="123" data-is-verified="true">
</user-profile-card>
5. CONSTANT_CASE (Upper Snake Case)
Pattern: All uppercase, words separated by underscores
Examples: MAX_LENGTH, API_KEY, IS_PRODUCTION, DEFAULT_TIMEOUT
Where it’s used:
- Most languages - Constants, environment variables, configuration values
- C/C++ - Preprocessor macros
- Python - Module-level constants
- Java - Static final fields
- Shell scripts - Environment variables
Why it works: Screams “don’t modify me!” and makes constants immediately identifiable.
Convert text to CONSTANT_CASE: Use our CONSTANT_CASE Converter
Real-World Example
// Good - CONSTANT_CASE for configuration
const API_BASE_URL = "https://api.example.com";
const MAX_RETRY_ATTEMPTS = 3;
const DEFAULT_TIMEOUT_MS = 5000;
const IS_PRODUCTION = process.env.NODE_ENV === "production";
function fetchUserData(userId) {
return fetch(`${API_BASE_URL}/users/${userId}`, {
timeout: DEFAULT_TIMEOUT_MS,
});
}
Language-Specific Conventions
Different programming languages have different cultural norms. Here’s a quick reference:
JavaScript/TypeScript
- Variables/Functions: camelCase -
getUserData - Classes/Types: PascalCase -
UserProfile - Constants: CONSTANT_CASE -
MAX_LENGTH - File names: kebab-case or camelCase -
user-profile.ts - Private fields:
_camelCaseor#camelCase
Quick convert: camelCase | PascalCase | CONSTANT_CASE
Python
- Variables/Functions: snake_case -
get_user_data - Classes: PascalCase -
UserProfile - Constants: CONSTANT_CASE -
MAX_LENGTH - Modules: snake_case -
user_profile.py - Private methods:
_snake_case
Quick convert: snake_case | PascalCase
Java
- Variables/Methods: camelCase -
getUserData - Classes/Interfaces: PascalCase -
UserProfile - Constants: CONSTANT_CASE -
MAX_LENGTH - Packages: lowercase -
com.example.userprofile
Quick convert: camelCase | PascalCase
C#
- Variables/Parameters: camelCase -
userData - Methods/Properties: PascalCase -
GetUserData - Classes/Interfaces: PascalCase -
UserProfile,IUserRepository - Constants: PascalCase -
MaxLength - Private fields:
_camelCase
Quick convert: camelCase | PascalCase
Ruby
- Variables/Methods: snake_case -
get_user_data - Classes/Modules: PascalCase -
UserProfile - Constants: CONSTANT_CASE -
MAX_LENGTH
Quick convert: snake_case | PascalCase
Go
- Variables/Functions: camelCase (private) or PascalCase (public) -
userDatavsUserData - Types: PascalCase -
UserProfile - Constants: camelCase or PascalCase based on visibility
- Packages: lowercase -
userprofile
Quick convert: camelCase | PascalCase
Rust
- Variables/Functions: snake_case -
get_user_data - Types/Traits: PascalCase -
UserProfile - Constants: CONSTANT_CASE -
MAX_LENGTH - Modules: snake_case -
user_profile
Quick convert: snake_case | PascalCase
Special Cases and Edge Scenarios
Database Naming Conventions
SQL Table Names:
- Traditional: snake_case -
user_profiles,order_items - Alternative: PascalCase -
UserProfiles,OrderItems
Column Names:
- Recommended: snake_case -
first_name,created_at - Why: Case-insensitive in many databases, avoiding quote-wrapped identifiers
Convert for databases: snake_case Converter
REST API Conventions
Endpoints:
- Standard: kebab-case -
/api/user-profiles,/api/order-items - Alternative: snake_case -
/api/user_profiles
JSON Keys:
- Standard: camelCase -
{"firstName": "Jane", "lastName": "Doe"} - Alternative: snake_case -
{"first_name": "Jane", "last_name": "Doe"}
Headers:
- Standard: Kebab-Case -
Content-Type,X-Api-Key
Convert for APIs: kebab-case | camelCase
CSS/SCSS Conventions
Class Names:
- BEM: kebab-case with double underscores/hyphens -
.user-profile__header--active - Standard: kebab-case -
.user-profile-card
Custom Properties:
- Standard: kebab-case with double hyphens -
--primary-color,--font-size-large
Convert for CSS: kebab-case Converter
URL Slugs and SEO
Recommended: kebab-case (always lowercase)
Why:
- URL-safe without encoding
- SEO-friendly and readable
- Works across all platforms
- Avoids case-sensitivity issues
Examples:
- ✅
example.com/blog/text-case-conventions - ✅
example.com/products/wireless-headphones - ❌
example.com/blog/Text_Case_Conventions - ❌
example.com/products/WirelessHeadphones
Convert URLs: kebab-case Converter
The Specialty Cases You’ll Encounter
Beyond the main conventions, there are some special formats worth knowing:
#hashtag #case
Pattern: Lowercase with hashtags
Examples: #javascript, #webdev, #coding
Where it’s used:
- Social media tags
- Markdown headers in some systems
- Informal categorization
Convert to hashtag case: #hashtag #case Converter
Title Case
Pattern: Major words capitalized, minor words lowercase
Examples: The Developer's Guide to Text, How to Build Better APIs
Where it’s used:
- Blog post titles
- Book titles
- Headers and headlines
- Documentation titles
Convert to Title Case: Title Case Converter
Sentence case
Pattern: First letter capitalized, rest lowercase except proper nouns
Examples: This is a sentence case example, Welcome to our API
Where it’s used:
- UI copy and microcopy
- Button labels
- Tooltips and help text
- Form labels
Convert to Sentence case: Sentence Case Converter
Common Anti-Patterns to Avoid
1. Inconsistent Conventions Within a File
// Bad - Mixed conventions
const user_name = "Jane";
const UserEmail = "jane@example.com";
const USERADDRESS = "123 Main St";
// Good - Consistent camelCase
const userName = "Jane";
const userEmail = "jane@example.com";
const userAddress = "123 Main St";
2. Fighting Language Conventions
# Bad - Using camelCase in Python
def getUserData():
userName = "Jane"
return userName
# Good - Following Python conventions
def get_user_data():
user_name = "Jane"
return user_name
3. Abbreviations Without Clarity
// Bad - Unclear abbreviations
const usrNm = "Jane";
const emlAddr = "jane@example.com";
// Good - Clear, full names
const userName = "Jane";
const emailAddress = "jane@example.com";
4. Overly Long Names
// Bad - Unnecessarily verbose
const userProfilePersonalInformationFirstNameValue = "Jane";
// Good - Concise but clear
const firstName = "Jane";
// or in context
const user = { firstName: "Jane" };
Decision Framework: Which Case Should I Use?
When you’re unsure which convention to use, ask yourself:
Question 1: What language am I using?
Follow the language’s standard conventions first. Don’t fight the ecosystem.
Question 2: What am I naming?
- Variable/Function? → Language-specific (usually camelCase or snake_case)
- Class/Type? → PascalCase
- Constant? → CONSTANT_CASE
- File? → kebab-case or snake_case
- URL? → kebab-case
- CSS class? → kebab-case
- Database? → snake_case
Question 3: What does my team use?
Consistency with your existing codebase trumps personal preference.
Question 4: What do established projects use?
Check popular open-source projects in your language for guidance.
Quick Conversion Tools for Every Case
Need to convert between different case conventions quickly? We’ve got you covered:
Core Programming Cases
- camelCase Converter - JavaScript, Java, C#
- PascalCase Converter - Classes and types
- snake_case Converter - Python, Ruby, databases
- kebab-case Converter - URLs, CSS, HTML
- CONSTANT_CASE Converter - Configuration values
Content & Formatting Cases
- Title Case Converter - Headlines and titles
- Sentence case Converter - UI copy
- Proper Case Converter - Every word capitalized
- #hashtag #case Converter - Social media
Text Transformation Cases
- UPPERCASE Converter - All caps
- lowercase Converter - All lowercase
- Toggle Case Converter - Swap case
- Alternating Case Converter - aLtErNaTiNg
- Inverse Case Converter - Invert all
- Random Case Converter - Randomize
Real-World Refactoring Example
Let’s see a complete before-and-after of fixing case convention issues:
Before: Mixed Conventions (Bad)
// Inconsistent mess
const User_Name = "Jane Doe";
const USEREMAIL = "jane@example.com";
const user_address = "123 Main St";
function GetUserInfo() {
return {
Name: User_Name,
Email: USEREMAIL,
address: user_address,
};
}
const API_endpoint = "https://api.example.com";
const max_retries = 3;
After: Consistent Conventions (Good)
// Clean, consistent naming
const userName = "Jane Doe";
const userEmail = "jane@example.com";
const userAddress = "123 Main St";
function getUserInfo() {
return {
name: userName,
email: userEmail,
address: userAddress,
};
}
const API_ENDPOINT = "https://api.example.com";
const MAX_RETRIES = 3;
What changed:
- Variables → camelCase
- Function → camelCase
- Object keys → camelCase
- Constants → CONSTANT_CASE
- Consistent style throughout
Convert your code: Use our Case Converters to clean up legacy code quickly.
Setting Up Automated Enforcement
Don’t rely on manual code reviews to catch case convention violations. Automate it:
ESLint (JavaScript/TypeScript)
{
"rules": {
"camelcase": ["error", { "properties": "never" }],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"]
},
{
"selector": "function",
"format": ["camelCase"]
},
{
"selector": "typeLike",
"format": ["PascalCase"]
}
]
}
}
Pylint (Python)
[BASIC]
variable-naming-style=snake_case
function-naming-style=snake_case
const-naming-style=UPPER_CASE
class-naming-style=PascalCase
RuboCop (Ruby)
Naming/VariableName:
EnforcedStyle: snake_case
Naming/MethodName:
EnforcedStyle: snake_case
The Bottom Line
Case conventions aren’t just pedantic style rules—they’re a communication protocol for your code.
When you write getUserData, other developers immediately know:
- It’s a function (camelCase)
- It retrieves data (get prefix)
- It’s about users (user)
When you write MAX_RETRY_ATTEMPTS, they know:
- It’s a constant (CONSTANT_CASE)
- It won’t change (uppercase = immutable)
- It defines a limit (MAX)
Good naming conventions make code self-documenting.
The specific convention matters less than consistency. Pick the right one for your language and ecosystem, then stick with it religiously.
Your future self (and your teammates) will thank you.
Quick Reference Cheat Sheet
| Case Style | Example | Primary Use Cases |
|---|---|---|
| camelCase | getUserData | JS/Java/C# variables & functions |
| PascalCase | UserProfile | Classes, types, interfaces |
| snake_case | get_user_data | Python, Ruby, SQL, files |
| kebab-case | get-user-data | URLs, CSS, HTML attributes |
| CONSTANT_CASE | MAX_LENGTH | Constants, env variables |
| Title Case | The User Guide | Titles, headlines |
| Sentence case | Welcome to our app | UI copy, labels |
Start Converting Today
Stop manually retyping text in different cases. Use our free converters:
Programming Essentials:
Content Formatting:
Text Transforms:
Social Media:
Published by FreeTextTools.org — because even dummy text deserves to speak more than one language.