camelCase vs snake_case — When to Use Each (And Why It Actually Matters)
The naming convention you choose does not affect how your code runs. It affects how easily humans can read, maintain and collaborate on it. And in a long-lived codebase, that gap between easy-to-read and hard-to-read accumulates into real time costs — slower onboarding, more bugs, more friction in code review.
This debate comes up in every code review, every team onboarding, and every style guide discussion. Junior developers get conflicting advice. Senior developers disagree in comment sections. The truth is that the answer is almost always "it depends on the language and context" — and that is actually a useful answer once you know the specifics.
This guide covers every major case format, which languages and contexts have standardised on each one, and how to convert between them instantly when you need to. By the end you will have a single reference you can return to every time the question comes up.
What Are the Main Naming Conventions?
Most developers know camelCase and snake_case — but there are several others in active daily use. Here is the complete family:
| Convention | Example | Also Called |
|---|---|---|
| camelCase | getUserName | Lower camel case |
| PascalCase | GetUserName | Upper camel case, UpperCamelCase |
| snake_case | get_user_name | Underscore case |
| SCREAMING_SNAKE_CASE | GET_USER_NAME | Constant case, UPPER_SNAKE_CASE |
| kebab-case | get-user-name | Hyphen case, spinal case |
| flatcase | getusername | Lowercase, no separator |
| UPPERCASE | GETUSERNAME | All caps |
| dot.case | get.user.name | Dot notation |
These are not arbitrary preferences that programmers invented to disagree about. Each convention evolved from the constraints and culture of specific languages and ecosystems. C used snake_case heavily because early C code was often written on terminals where lowercase was easier to type and read at low resolution. Java came along with object-oriented patterns that made camelCase feel natural for method names. Python made an explicit choice in its official style guide.
Understanding the history helps because it explains why the conventions are not interchangeable. Each one is optimised for a specific context. Trying to use camelCase in Python or snake_case in a JavaScript codebase is not wrong in a runtime sense — it just signals that whoever wrote the code does not know the ecosystem conventions, which creates friction.
camelCase — What It Is and When to Use It
camelCase starts with a lowercase letter. Each subsequent word starts with an uppercase letter. No spaces, hyphens or underscores. The name comes from the visual similarity to a camel's humps — the uppercase letters create a bumpy silhouette against the lowercase body.
// JavaScript — variables and functions
const userName = "john_doe";
const totalWordCount = 1450;
function getUserById(userId) {
return database.find(userId);
}
// React — props and state
const [isLoading, setIsLoading] = useState(false);
const [wordCount, setWordCount] = useState(0);Where camelCase is the standard:
| Language / Context | Where camelCase Is Used |
|---|---|
| JavaScript | Variables, functions, parameters |
| TypeScript | Variables, functions, parameters |
| Java | Variables, methods, parameters |
| Swift | Variables, functions, parameters |
| Kotlin | Variables, functions, parameters |
| JSON | Key names (common convention) |
| React | Props, state variables, hooks |
| CSS-in-JS | Style property names |
JavaScript landed on camelCase largely because Java was the dominant language when JavaScript was designed in 1995, and Brendan Eich pulled heavily from Java's syntax conventions. Java had already settled on camelCase for methods and variables decades earlier, influenced by Smalltalk and C++ communities where the style was already widespread.
React reinforced camelCase as the convention for props and event handlers — onClick, onChange, onSubmit — because JSX maps these directly to the browser's JavaScript event model. CSS-in-JS libraries like styled-components and Emotion followed suit, converting CSS property names from background-color to backgroundColor.
One practical advantage of camelCase over snake_case is that it requires one fewer keystroke per word boundary — no shift to type underscore. For long variable names in a language you write hundreds of times a day, this adds up. It is a small ergonomic advantage, not a quality argument, but it is real.
snake_case — What It Is and When to Use It
snake_case uses all lowercase letters with words separated by underscores. It is highly readable because underscores create clear visual separation between words without mixing cases — the eye does not need to detect a capital letter to find the word boundary. Many developers find long snake_case names easier to read at a glance than their camelCase equivalents.
# Python — variables, functions, modules
user_name = "john_doe"
total_word_count = 1450
def get_user_by_id(user_id):
return database.find(user_id)
# Python — file names
word_counter.py
reading_time_calculator.py
# Database — column names
CREATE TABLE users (
user_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
created_at TIMESTAMP
);Where snake_case is the standard:
| Language / Context | Where snake_case Is Used |
|---|---|
| Python | Everything — PEP 8 standard |
| Ruby | Variables, methods, symbols |
| PHP | Variables, functions (common) |
| SQL / Databases | Table names, column names |
| C / C++ | Variables, functions (common) |
| Rust | Variables, functions, modules |
| File names | Python files, shell scripts |
| Environment variables | Often SCREAMING_SNAKE_CASE |
Python's PEP 8 — published in 2001 — is one of the most influential style documents in programming history. It explicitly states: "Function names should be lowercase, with words separated by underscores as necessary to improve readability." The Python community has largely treated this as law rather than suggestion. A Python PR withcamelCase variable names will almost certainly get a review comment requesting it be changed to snake_case before merge.
Database column names are almost universally snake_case regardless of what language is querying them. SQL is case-insensitive for keywords but consistentsnake_case for identifiers has become the de facto standard because it reads clearly in queries, avoids quoting requirements in most dialects, and matches what most ORMs expect when mapping database columns to model properties.
One frequent pain point is the boundary between a JavaScript or TypeScript frontend and a Python or SQL backend. The API returns user_id, first_name, created_at — but the frontend code wants userId, firstName, createdAt. This is a real, recurring problem in full-stack development, and the cleanest solution is to do a single transformation at the API boundary rather than mixing conventions throughout either codebase.
PascalCase — Classes and Components
PascalCase is like camelCase but the first letter is also uppercase. It is sometimes called UpperCamelCase to make the relationship explicit. Almost universally, seeing PascalCase in code means you are looking at a class, a type, or a React component.
// JavaScript / React — components
function UserProfile({ userName, avatarUrl }) {
return <div>{userName}</div>;
}
// TypeScript — interfaces and types
interface UserAccount {
userId: number;
userName: string;
createdAt: Date;
}
// Java / C# — class names
public class UserController {
private UserService userService;
}Where PascalCase is the standard:
| Context | PascalCase Usage |
|---|---|
| All languages | Class names |
| React / JSX | Component names |
| TypeScript | Interfaces, type aliases, enums |
| C# | Almost everything — methods too |
| Java | Class names, interface names |
PascalCase for class names is one of the most consistent conventions across the entire programming landscape. Python uses it despite preferring snake_case for everything else. JavaScript uses it for React components even though variables and functions use camelCase. When you encounter PascalCase, you can be fairly confident you are looking at something you instantiate or render, not something you call as a function or read as a value.
React enforces this convention in a meaningful way: JSX interprets any component starting with a lowercase letter as an HTML element. Writing <userProfile /> in JSX renders an unknown HTML element. Writing <UserProfile /> renders your React component. This is not just a style convention in React — it is a functional requirement.
kebab-case — The Web's Favourite
kebab-case uses all lowercase letters with words separated by hyphens. The name comes from the visual resemblance to pieces of food on a kebab skewer. It cannot be used for variable names in most programming languages because the hyphen is the subtraction operator — get-user-name in JavaScript means get minus user minus name, not a multi-word identifier. But in contexts where hyphens are just characters, it thrives.
/* CSS — class names and custom properties */
.user-profile { }
.word-counter-tool { }
.is-loading { }
--primary-color: #2563eb;
/* HTML — data and aria attributes */
<div data-user-id="123">
<input aria-label="word-count">
/* URLs — universal standard */
/blog/camelcase-vs-snake-case
/tools/word-counter
/tools/reading-time-calculatorWhere kebab-case is the standard:
| Context | kebab-case Usage |
|---|---|
| CSS | Class names, custom properties |
| HTML | Data attributes, aria attributes |
| URLs / slugs | Universal standard |
| File names | HTML, CSS files |
| NPM packages | Package names |
| Lisp / Clojure | Variable names |
kebab-case dominates URLs because it is the most readable option in a browser address bar. Hyphens read as natural word separators — your brain parses /word-counter-tool as three separate words instantly. Underscores visually disappear in hyperlinks because the underline decoration merges with the underscore character, making /word_counter_tool harder to read in a hyperlink context.
Google's own documentation explicitly recommends hyphens as word separators in URLs and treats them as true word boundaries for indexing. A URL like /camelcase-vs-snake-case helps Google understand that this page is about four distinct concepts: camelcase, vs, snake, case. Underscores create ambiguity — Google treats snake_case as one token, not two. For blog posts and tool pages where the slug directly reflects the target keyword, this SEO distinction is worth taking seriously.
Quick Reference — Which Convention for What
Bookmark this. It is the cheat sheet you will actually use:
| Use Case | Convention | Example |
|---|---|---|
| JavaScript variable | camelCase | userName |
| JavaScript function | camelCase | getUserData() |
| JavaScript class | PascalCase | UserController |
| React component | PascalCase | UserProfile |
| TypeScript interface | PascalCase | UserAccount |
| Python variable | snake_case | user_name |
| Python function | snake_case | get_user_data() |
| Python class | PascalCase | UserController |
| Python constant | SCREAMING_SNAKE | MAX_RETRY_COUNT |
| CSS class | kebab-case | .user-profile |
| HTML attribute | kebab-case | data-user-id |
| URL slug | kebab-case | /user-profile |
| Database column | snake_case | user_name |
| Environment variable | SCREAMING_SNAKE | API_SECRET_KEY |
| NPM package name | kebab-case | react-query |
| JSON key | camelCase | userId |
| File name (JS) | kebab-case or camelCase | user-profile.js |
| File name (Python) | snake_case | user_profile.py |
Within a single codebase, consistency matters more than which convention you pick. A codebase that uses snake_case everywhere — even in JavaScript — is far easier to work in than one that mixes camelCase and snake_case in the same file. The cognitive friction of context-switching between conventions inside a single function is genuinely disruptive, even for experienced developers.
The table above reflects what the wider ecosystem has standardised on — which means following it makes your code readable to other developers without additional explanation. Deviating from these conventions is always possible, but it always comes with a readability cost that you will need to justify to every new person who touches the code.
How to Convert Between Cases Instantly
Moving code between languages often means converting naming conventions. When you port a Python function to JavaScript, every user_name becomes userName. When you copy a database schema into your TypeScript types, every created_at becomes createdAt. In a small file this is manageable. In a real codebase with hundreds of identifiers, doing it manually is tedious and error-prone.
The same problem comes up when writing documentation, API contracts, or config files where the convention is different from the language you are coming from. You should not be spending mental energy on mechanical case transformations. That is exactly the kind of repetitive work that a tool should handle.
Convert Between Any Case Format Instantly
Paste any text into our free Text Case Converter and convert to camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE_CASE and more with a single click. Perfect for developers switching between languages or codebases.
How to Use PickBlend's Text Case Converter
Open the Text Case Converter and paste your variable names, function names, or any text you want to convert. You can paste a single identifier or an entire list — one name per line works well for converting batches of variable names at once.
Click the target case format button — camelCase, PascalCase, snake_case, kebab-case, UPPERCASE, sentence case, or title case. The conversion happens instantly, and the result appears in the output panel below. No page reload, no waiting.
Copy the converted output with the copy button and paste it directly into your editor. The whole process takes a few seconds. For developers who regularly work across multiple languages or maintain API boundaries between different ecosystems, this becomes one of the most-used tools in your daily workflow.
Common Mistakes Developers Make With Naming
The biggest naming mistakes are not about choosing the wrong convention — they are about applying conventions inconsistently. Here are the six that come up most often in code reviews:
1. Mixing conventions in the same file. Using user_name and userName in the same JavaScript file is harder to read than either alone. It signals inconsistent code standards and forces the reader to constantly re-establish context. Pick one and enforce it through a linter like ESLint or Prettier.
2. Abbreviating inconsistently. usrNm, userName, uname — pick one and stick to it across the entire codebase. Abbreviated names save keystrokes at write time but cost comprehension at read time, and three different abbreviations for the same concept is the worst of all worlds.
3. Single-letter variables outside of loops. x, y, n are fine as counters in a tight loop where the scope is obvious. Using them for business logic variables — a user object, a word count, a response payload — produces code that is completely opaque to anyone reading it later, including yourself in six months.
4. Ignoring the language's official style guide. Python has PEP 8. JavaScript has the Airbnb and Google style guides. Go has gofmt and the official effective Go documentation. Ignoring these does not make you a maverick — it creates friction for every other developer who has to work in your code. Most professional teams enforce these through automated linting in CI.
5. Using different conventions for the same concept at an API boundary. If your backend returns user_id and your frontend uses userId, you need a transformation somewhere. The worst outcome is doing this transformation inconsistently in multiple places. The best outcome is a single serialisation layer that handles all transformations at the boundary, leaving each codebase internally consistent.
6. Hungarian notation in modern code. Prefixing variables with their type — strUserName, intCount, bIsLoading — was common in 1990s C and VBA code when IDEs could not show types on hover. In 2026 with TypeScript, Python type hints, and modern IDE tooling, it is noise. It lengthens names and makes refactoring harder without adding meaningful information.
Frequently Asked Questions
Should I use camelCase or snake_case in JavaScript?
Use camelCase for variables, functions and parameters in JavaScript. This is the convention established by the language's core libraries and followed by virtually every major JavaScript style guide including Airbnb, Google and StandardJS. Use PascalCase for class names and React components. Use SCREAMING_SNAKE_CASE for true constants — values that should never change across the lifetime of the program.
Why does Python use snake_case instead of camelCase?
Python uses snake_case because of PEP 8 — the official Python style guide published in 2001 by Guido van Rossum, the language's creator. PEP 8 recommends snake_case for variables and functions because Python prioritises readability and snake_case is considered more readable for the descriptive, English-phrase-like names Python encourages. The Python community treats PEP 8 compliance as a mark of professional code quality — not following it is a genuine signal that someone is new to the ecosystem.
Is PascalCase the same as camelCase?
PascalCase and camelCase are related but different. camelCase starts with a lowercase letter (getUserName). PascalCase starts with an uppercase letter (GetUserName). PascalCase is sometimes called UpperCamelCase to make this relationship explicit. In practice, camelCase is for variables and functions while PascalCase is almost universally reserved for classes, types and React components.
Why is kebab-case used for URLs and CSS?
kebab-case dominates URLs because hyphens are safe URL characters and Google explicitly treats them as word separators — making kebab-case slugs better for SEO than underscored or camelCased alternatives. For CSS class names, it became the convention because CSS is case-insensitive and hyphens create clear visual word boundaries without mixing cases. It cannot be used for JavaScript variable names because the hyphen is the subtraction operator in that context.
Does naming convention affect SEO?
For URL slugs, yes — naming convention directly affects SEO. Google treats hyphens as word separators in URLs, meaning /camelcase-vs-snake-case is indexed as four separate words. Underscores are not treated as separators, so /camelcase_vs_snake_case is indexed as one long token. For variable names inside your application code, naming conventions have no effect on SEO whatsoever — search engines never see your variable names.