Programming Naming Conventions Explained: camelCase, PascalCase, snake_case & More
Learn the difference between camelCase, PascalCase, snake_case, kebab-case and UPPER_SNAKE_CASE — which languages use which, and how to name things cleanly.
On this page
In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code. Using naming conventions consistently leads to more readable, maintainable, and cleaner code.
Compilers and runtimes don’t care what you name your variables, as long as they are syntactically valid. But humans do. Let’s break down the most popular naming conventions used in software development, how they differ, and when to use them.
The Major Naming Conventions
Here are the five most commonly used naming cases across modern programming ecosystems:
Capitalizes the first letter of each word except the first one. Primarily used in JavaScript, TypeScript, and Java for variable and function names.
Capitalizes the first letter of every single word. Standard in C#, Java, and TypeScript for class names and component names in React/Astro.
All letters are lowercase, and words are separated by underscores. The default convention in Python, Rust, and database column names.
All letters are lowercase, separated by hyphens (dashes). Standard for HTML class/ID names, CSS properties, and URLs.
All uppercase letters separated by underscores. Used universally across almost all languages for constants and global configuration values.
Operational Naming Standards
Regardless of the case style you use, follow these core principles for readability:
Do
- Be descriptive: Use
fetchUserData()instead off()orfd(). - Match domain: Choose names that map directly to the business logic (e.g.
invoiceTotal). - Use standard case: Follow your team’s style guide or the language’s native specs.
Don't
- Avoid abbreviations:
usrAddrTempis much harder to parse thantemporaryUserAddress. - No redundant names: Inside a
Userclass, name the propertyemail, notuserEmail. - Never mix styles: Don’t combine
camelCaseandsnake_casein the same codebase.
Conclusion
Naming conventions are not rules set in stone by computer hardware. They are agreements made between developers to lower cognitive load when reading and analyzing code. When starting a project, establish these rules early and enforce them automatically using tools like ESLint and Prettier.
Frequently asked questions
What is the difference between camelCase and PascalCase?
camelCase lowercases the first word and capitalizes every following word (userProfileImage); PascalCase capitalizes every word including the first (DatabaseConnector). camelCase is standard for variables and functions in JavaScript and Java, while PascalCase is reserved for class, type and component names.
Which naming convention does Python use?
Python uses snake_case for variables, functions and module names (get_user_data), PascalCase for class names, and UPPER_SNAKE_CASE for constants. This is codified in PEP 8, Python's official style guide, and enforced by most Python linters out of the box.
Should you mix naming conventions in one codebase?
No. Mixing camelCase and snake_case in the same codebase increases cognitive load and causes real bugs, such as mismatched keys between APIs and databases. Pick the convention native to your language, document it, and enforce it automatically with tools like ESLint or Prettier.
What is kebab-case used for?
kebab-case joins lowercase words with hyphens (main-content-wrapper) and is the standard for HTML class and ID names, CSS properties, file names and URLs. It is not usable for variable names in most programming languages because the hyphen is parsed as a minus operator.
/* Comments */
Comments are offline right now — we reconnect automatically, nothing is lost.