Text Case Conversion: When to Use camelCase, snake_case, and More
Naming things is one of the two hardest problems in computer science (alongside cache invalidation and off-by-one errors). Choosing the right case convention for your variables, functions, classes, and file names is not just about aesthetics -- it affects code readability, team collaboration, and even how well your code integrates with frameworks and libraries.
This guide explains every major naming convention, when to use each one, and which languages and contexts prefer which style.
The Major Case Styles Explained
| Style | Example | Also Known As |
|---|---|---|
| camelCase | getUserName | Lower camel case |
| PascalCase | UserAccount | Upper camel case |
| snake_case | user_name | Underscore case |
| SCREAMING_SNAKE_CASE | MAX_RETRIES | Constant case |
| kebab-case | user-profile | Dash case, hyphen case |
| UPPERCASE | USERNAME | All caps |
| lowercase | username | All lower |
| Title Case | User Name | Start case |
| Sentence case | User name here | -- |
| dot.case | user.name | Dot notation |
When to Use Each Convention
camelCase
The go-to convention for variables and functions in JavaScript, TypeScript, Java, and C#. The first word is lowercase, and each subsequent word is capitalized. It is also the standard for JSON keys in most JavaScript-based APIs.
let userName = "Alice";
function getUserProfile() { ... }
PascalCase
Used for class names, components, and types across nearly all languages. In React, all component names must be PascalCase. It is also the convention for C# methods and public properties.
class UserAccount { ... }
function ProfileCard() { return <div>...</div>; }
snake_case
The standard for variables and functions in Python, Ruby, Rust, and PHP. It is also the convention for database column names in most SQL databases and for JSON keys in Python-based APIs.
user_name = "Alice"
def get_user_profile():
pass
SCREAMING_SNAKE_CASE
Reserved for constants in virtually every language. When you see all caps with underscores, it signals that a value should not be modified.
const MAX_RETRIES = 3;
const API_BASE_URL = "https://api.example.com";
kebab-case
The standard for URLs, CSS class names, and file names in web projects. Hyphens are more readable than underscores in URLs and are the convention in HTML attribute names.
<div class="user-profile-card">...</div>
/* file: user-profile.css */
Convert Text Between Any Case Style
Paste your text and instantly convert between camelCase, snake_case, PascalCase, and more.
Try the Text Case ConverterLanguage-Specific Conventions
JavaScript / TypeScript
- Variables and functions:
camelCase - Classes and React components:
PascalCase - Constants:
SCREAMING_SNAKE_CASE - File names:
kebab-caseorcamelCase(varies by project)
Python
- Variables and functions:
snake_case - Classes:
PascalCase - Constants:
SCREAMING_SNAKE_CASE - Modules and packages:
snake_case
Java / C#
- Variables and method parameters:
camelCase - Methods:
camelCase(Java) orPascalCase(C#) - Classes and interfaces:
PascalCase - Constants:
SCREAMING_SNAKE_CASE
Go
- Exported (public) names:
PascalCase - Unexported (private) names:
camelCase - Acronyms stay uppercase:
HTTPClient, notHttpClient
CSS / HTML
- Class names:
kebab-case - CSS custom properties:
--kebab-case - Data attributes:
data-kebab-case - BEM methodology:
block__element--modifier
Databases
- Table and column names:
snake_case(PostgreSQL, MySQL) orPascalCase(SQL Server) - Avoid spaces and special characters in identifiers
The most important rule is to be consistent within your project. If your team uses camelCase for JSON keys, do not mix in snake_case. Use a linter to enforce conventions automatically. When working with JSON APIs, our JSON Formatter can help you spot inconsistent key naming.
Troubleshooting Case-Related Issues
My CSS class names are not applying
CSS class names are case-sensitive. If your HTML says class="UserCard" but your CSS targets .usercard, the styles will not apply. Stick to kebab-case for CSS classes to avoid this entirely.
My imports are failing on Linux but work on Mac/Windows
Mac and Windows file systems are case-insensitive by default, but Linux is case-sensitive. A file named UserProfile.js will not be found by import './userprofile.js' on Linux. Always match the exact case of file names in your imports.
My API returns different cases than expected
When a frontend (JavaScript, using camelCase) communicates with a backend (Python, using snake_case), you need a serialization layer that converts between them. Most frameworks (like Django REST Framework or NestJS) have built-in support for this.
Database queries are case-sensitive when they should not be
PostgreSQL treats unquoted identifiers as lowercase. If you create a column as "userName" (quoted), you must always quote it. Use snake_case without quotes to avoid this problem.
Getting naming conventions right saves time in code reviews, reduces bugs from case mismatches, and makes your codebase more welcoming to new contributors. Use our free Text Case Converter to quickly transform text between any convention, and pick a style guide that matches your language's community standards.