Why does JavaScript use camelCase while Python prefers snake_case? Why do CSS classes use kebab-case? These aren't arbitrary choices—they're conventions that improve code readability and maintain consistency. Let's explore them all.
Common Case Styles
lowercase
All letters in lowercase. Simple, humble, unassuming.
Example: hello world
Use: Email addresses, URLs, some file names
UPPERCASE
All letters capitalized. LOUD AND CLEAR.
Example: HELLO WORLD
Use: Constants in programming, acronyms, emphasis
Title Case
First letter of each major word capitalized.
Example: Hello World
Use: Headlines, book titles, proper nouns
Sentence case
Only the first letter of the first word capitalized.
Example: Hello world
Use: Regular sentences, UI text, descriptions
Programming Case Conventions
camelCase
First word lowercase, subsequent words capitalized, no spaces.
Example: getUserName, totalItemCount
Use: JavaScript variables/functions, Java methods, JSON keys
PascalCase (UpperCamelCase)
Like camelCase but first word also capitalized.
Example: UserProfile, HttpRequest
Use: Class names in most languages, React components, C# methods
snake_case
All lowercase with underscores between words.
Example: user_name, total_count
Use: Python variables/functions, Ruby, database columns
SCREAMING_SNAKE_CASE
All uppercase with underscores.
Example: MAX_SIZE, API_KEY
Use: Constants in most languages, environment variables
kebab-case
All lowercase with hyphens between words.
Example: user-profile, main-content
Use: CSS classes, URL slugs, HTML attributes, file names
Why kebab-case can't be used in most programming languages: The hyphen is interpreted as a minus sign. my-variable would be read as my minus variable.
Convention by Language/Context
- JavaScript: camelCase for variables/functions, PascalCase for classes
- Python: snake_case for most things, PascalCase for classes
- Java: camelCase for methods/variables, PascalCase for classes
- CSS: kebab-case for classes and IDs
- SQL: UPPERCASE for keywords, snake_case for identifiers
- REST APIs: Often snake_case or camelCase for JSON
- URLs: kebab-case for slugs
Why Consistency Matters
Mixing conventions makes code harder to read and maintain:
- Inconsistent naming forces mental context-switching
- Harder to search/replace or refactor
- Signals inexperience or lack of attention to detail
- Can cause bugs (case-sensitive languages won't find misnamed references)
Special Cases
Acronyms in Case Conventions
How do you handle "HTML" or "API" in camelCase?
htmlParserorHTMLParser?apiKeyorAPIKey?
Style guides vary. Some treat acronyms as words (htmlParser), others preserve them (HTMLParser). Pick one and be consistent.
Convert Text Case Instantly
Transform text between any case style with one click.
Open Case Converter →The Bottom Line
Case conventions are about communication. They help developers understand code at a glance—is this a class or a function? A constant or a variable? Follow the conventions of your language and team, and your code will be easier for everyone to read.