10 Text Case Conventions Every Developer Should Know
Master naming conventions and write more readable, professional code
π‘ Quick Reference
- camelCase: firstName, getUserData()
- PascalCase: UserAccount, ComponentName
- snake_case: first_name, get_user_data()
- kebab-case: my-component, user-profile
- SCREAMING_SNAKE_CASE: MAX_SIZE, API_KEY
Text case conventions aren't just about aestheticsβthey're a fundamental part of writing clean, maintainable code. Whether you're naming variables, functions, files, or URLs, choosing the right convention improves readability and prevents bugs.
1. camelCase
The most common convention in JavaScript and Java. First word lowercase, subsequent words capitalized.
When to Use:
- β JavaScript variables and functions
- β Java methods and properties
- β TypeScript interfaces (alternative to PascalCase)
- β JSON property names
// JavaScript Example
const firstName = "John";
const userAge = 25;
function calculateTotalPrice(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
// Try it yourself at text-case.com
const myVariableName = "Example";2. PascalCase
Every word starts with a capital letter. Essential for class names and components.
When to Use:
- β Class names in all languages
- β React/Vue components
- β Constructor functions
- β Type definitions and interfaces
// React Component Example
class UserProfile extends React.Component {
render() {
return <div>Profile</div>;
}
}
// TypeScript Interface
interface UserAccount {
firstName: string;
lastName: string;
}3. snake_case
All lowercase with underscores between words. The standard in Python and database design.
When to Use:
- β Python variables and functions
- β Database table and column names
- β Configuration file keys
- β Environment variables (lowercase version)
# Python Example
user_name = "John Doe"
total_count = 100
def get_user_by_id(user_id):
return database.query(user_id)
# Database Schema
CREATE TABLE user_accounts (
user_id INT PRIMARY KEY,
first_name VARCHAR(50),
created_at TIMESTAMP
);4. kebab-case
All lowercase with hyphens between words. Perfect for URLs and CSS.
When to Use:
- β URLs and slugs
- β CSS class names
- β HTML attributes
- β File names (alternative to snake_case)
<!-- HTML/CSS Example -->
<div class="user-profile-card">
<button class="primary-action-button">
Click Me
</button>
</div>
/* CSS */
.user-profile-card {
background-color: white;
}
/* URL Slug */
https://example.com/blog/text-case-conventions5. SCREAMING_SNAKE_CASE
All uppercase with underscores. Used for constants and environment variables.
When to Use:
- β Global constants
- β Environment variables
- β Configuration values
- β Enum values (some languages)
// JavaScript Constants
const MAX_RETRY_COUNT = 3;
const API_BASE_URL = "https://api.example.com";
const DEFAULT_TIMEOUT = 5000;
// Environment Variables
DATABASE_URL=postgresql://localhost/mydb
API_KEY=abc123xyz789
NODE_ENV=production6. UPPERCASE
All letters capitalized with no separators. Rare but used for specific purposes.
When to Use:
- β SQL keywords
- β Acronyms in code (HTML, API, URL)
- β Single-word constants
7. lowercase
All lowercase, no separators. Minimal but sometimes necessary.
When to Use:
- β Domain names
- β Email addresses
- β Package names (npm, pip)
- β Hashtags
8. Train-Case (or HTTP-Header-Case)
Each word capitalized with hyphens. Primarily used in HTTP headers.
When to Use:
- β HTTP headers
- β Email headers
Content-Type: application/json
Authorization: Bearer token123
Cache-Control: no-cache9. dot.case
Words separated by dots. Used in specific technical contexts.
When to Use:
- β Java package names
- β Domain names
- β File extensions
- β Configuration paths
// Java Package
package com.example.myapp.utils;
// Domain
api.example.com
// Config Path
database.connection.timeout10. path/case
Words separated by slashes. Used for file paths and hierarchies.
When to Use:
- β File and directory paths
- β URL paths
- β Route definitions
π― Quick Decision Guide
JavaScript? Use camelCase for variables/functions, PascalCase for classes
Python? Use snake_case for everything except classes (PascalCase)
URLs? Always use kebab-case
CSS? Use kebab-case for class names
Constants? Use SCREAMING_SNAKE_CASE
Databases? Use snake_case for tables and columns
β‘ Try Our Text Case Converters
Convert between all these case styles instantly with our free online tools:
Frequently Asked Questions
Ready to Convert Your Text?
Use our free text case converters to transform your text between any of these 10 conventions instantly. Perfect for developers, content creators, and writers.
Try Free Text Case Converters β