The Quick Answer
Different programming languages and contexts use different naming conventions. Here are the most common ones:
| Convention | Example | Primary Use |
|---|---|---|
| camelCase | getUserName |
JavaScript, Java, TypeScript variables/functions |
| PascalCase | GetUserName |
Class names, React components, C# methods |
| snake_case | get_user_name |
Python, Ruby, database columns |
| kebab-case | get-user-name |
CSS classes, URL slugs, CLI flags |
| CONSTANT_CASE | MAX_RETRY_COUNT |
Constants, environment variables |
| dot.case | get.user.name |
Config keys, Java packages |
| Title Case | Get User Name |
Headings, titles |
| UPPERCASE | GET USER NAME |
Acronyms, emphasis |
| lowercase | get user name |
Normalization, search indexing |
Need to convert between these? Use our text case converter — it handles all of them.
Why Naming Conventions Exist
Naming conventions serve three purposes:
- Readability — Consistent casing makes code easier to scan
- Distinction — Different cases signal different roles (variable vs. class vs. constant)
- Tooling — Linters, formatters, and auto-complete rely on consistent patterns
Most style guides enforce one convention per context. Mixing styles within a codebase creates friction and bugs.
camelCase
Pattern: First word lowercase, subsequent words capitalized. No separators.
getUserName
isValid
totalItemCount
parseJSON
Used in:
- JavaScript / TypeScript — variables, functions, object properties
- Java — variables, methods, parameters
- Go — unexported identifiers
- Swift — variables, functions
- JSON keys (by convention)
Why it works: Compact, readable, and the lowercase start signals "this is a value, not a type."
Edge Cases
- Single-word identifiers are just lowercase:
name,count - Acronyms: opinions vary. Some write
parseJSON, othersparseJson. The trend leans toward treating acronyms as words:getHtmlElementrather thangetHTMLElement. Check your style guide.
PascalCase
Pattern: Every word capitalized. No separators. Also called UpperCamelCase.
GetUserName
HttpClient
ShoppingCart
MyComponent
Used in:
- JavaScript / TypeScript — class names, React/Vue/Angular components
- C# — methods, properties, class names, namespaces
- Java — class names, interfaces
- Go — exported (public) identifiers
- Python — class names (per PEP 8)
The key distinction: PascalCase typically means "this is a type or a constructor." When you see UserProfile, you know it's a class, not an instance.
snake_case
Pattern: All lowercase, words separated by underscores.
get_user_name
is_valid
total_item_count
created_at
Used in:
- Python — variables, functions, modules, file names (PEP 8)
- Ruby — variables, methods, file names
- Rust — variables, functions, modules
- SQL / databases — table names, column names
- File names in many projects
Why it works: Highly readable, especially for longer identifiers. The underscores make word boundaries unambiguous.
SCREAMING_SNAKE_CASE
An uppercase variant (MAX_CONNECTIONS) used for constants. See CONSTANT_CASE below.
kebab-case
Pattern: All lowercase, words separated by hyphens.
get-user-name
my-component
primary-button
text-case-converter
Used in:
- CSS — class names, custom properties (
--primary-color) - HTML — attribute names (
data-user-id) - URL slugs (
/blog/text-case-conventions-explained) - CLI flags (
--output-format) - npm package names
- File names in some projects
Important limitation: Most programming languages don't allow hyphens in identifiers, so kebab-case is mainly used in markup, stylesheets, and URLs — not in code variables.
CONSTANT_CASE
Pattern: All uppercase, words separated by underscores. Also called SCREAMING_SNAKE_CASE or MACRO_CASE.
MAX_RETRY_COUNT
API_BASE_URL
DATABASE_HOST
DEFAULT_TIMEOUT_MS
Used in:
- Constants in JavaScript, Python, Java, C, C++, Rust, Go
- Environment variables (
NODE_ENV,DATABASE_URL) - C preprocessor macros
- Enum values in many languages
The convention: Uppercase signals "this value should not be reassigned." It's a visual contract between the author and every future reader.
dot.case
Pattern: All lowercase, words separated by dots.
com.example.app
my.config.value
logging.level.root
server.port
Used in:
- Java package names (
com.example.myapp) - Configuration file keys (Spring Boot, Gradle, Maven)
- Property paths in object notation
- Some logging frameworks
Practical note: dot.case is less common as a general naming convention and more tied to specific ecosystems. If you're configuring a Java/Spring application or writing property files, you'll encounter it constantly.
Title Case and Sentence Case
Title Case
Capitalizes the first letter of each word: The Quick Brown Fox
Used for headings, book titles, article titles, and UI labels. Style guides differ on whether to capitalize small words like "the", "of", "and" — most heading styles leave short prepositions and articles lowercase unless they start the title.
Sentence case
Capitalizes only the first letter of the first word (and proper nouns): The quick brown fox
Used for body text, UI labels, button text, and anywhere natural language appears. Sentence case reads more naturally and is the trend in modern UI design.
Conversion Rules
Converting between case styles follows a two-step process:
- Split the input into individual words
- Join them using the target convention
The tricky part is step 1 — the splitter needs to handle all input formats:
- Spaces:
"get user name"→["get", "user", "name"] - Underscores:
"get_user_name"→["get", "user", "name"] - Hyphens:
"get-user-name"→["get", "user", "name"] - camelCase boundaries:
"getUserName"→["get", "User", "Name"] - Acronym boundaries:
"HTMLParser"→["HTML", "Parser"]
Once you have the word array, joining is straightforward:
| Target | Join rule |
|---|---|
| camelCase | First word lowercase, rest capitalized, no separator |
| PascalCase | All words capitalized, no separator |
| snake_case | All lowercase, joined by _ |
| kebab-case | All lowercase, joined by - |
| CONSTANT_CASE | All uppercase, joined by _ |
| dot.case | All lowercase, joined by . |
Our text case converter implements this exact logic in your browser.
Language-Specific Style Guides
Each language has an accepted standard. Here's a quick reference:
JavaScript / TypeScript
- Variables and functions:
camelCase - Classes and components:
PascalCase - Constants:
CONSTANT_CASE - CSS classes (in JSX):
kebab-case - File names: varies (
camelCaseorkebab-case)
Python (PEP 8)
- Variables and functions:
snake_case - Classes:
PascalCase - Constants:
CONSTANT_CASE - Modules and packages:
snake_case - File names:
snake_case
Java
- Variables and methods:
camelCase - Classes and interfaces:
PascalCase - Constants:
CONSTANT_CASE - Packages:
dot.case(all lowercase)
Go
- Exported (public):
PascalCase - Unexported (private):
camelCase - Constants:
PascalCaseorcamelCase(not CONSTANT_CASE) - Packages:
lowercase(single word preferred)
CSS
- Class names:
kebab-case - Custom properties:
--kebab-case - IDs:
kebab-case - BEM methodology:
block__element--modifier
Ruby
- Variables and methods:
snake_case - Classes and modules:
PascalCase - Constants:
CONSTANT_CASE - File names:
snake_case
Rust
- Variables and functions:
snake_case - Types and traits:
PascalCase - Constants:
CONSTANT_CASE - Modules:
snake_case
Common Mistakes
Inconsistent acronym handling. Pick one approach and stick with it. Either getHTMLElement or getHtmlElement — not both in the same codebase.
Mixing conventions within a role. If your variables are camelCase, all variables should be camelCase. One user_name among twenty userNames creates confusion.
Using the wrong case for the ecosystem. Writing getUserName in a Python file or get_user_name in JavaScript technically works, but it signals unfamiliarity with the language and creates friction for collaborators.
Forgetting about file names. File naming conventions vary. React projects often use PascalCase for component files (UserProfile.tsx), while Python uses snake_case (user_profile.py). Match the ecosystem.
Frequently Asked Questions
What is the best naming convention?
There is no universal "best." Use whatever your language's official style guide recommends. Consistency within a project matters more than which convention you choose.
Can I mix naming conventions in one project?
Yes, but deliberately — different conventions for different roles. For example, in JavaScript: camelCase for variables, PascalCase for classes, CONSTANT_CASE for constants, and kebab-case for CSS. Mixing within the same role creates confusion.
What about acronyms in camelCase?
Both parseJSON and parseJson are used in practice. The modern trend (adopted by Google's style guide and many others) treats acronyms as regular words: getHtmlElement, parseJson, xmlHttpRequest. This avoids ambiguity with consecutive acronyms.
Is kebab-case the same as dash-case?
Yes. "kebab-case," "dash-case," and "lisp-case" all refer to the same convention: lowercase words joined by hyphens.
How do I convert camelCase text to snake_case manually?
Insert an underscore before each uppercase letter, then convert everything to lowercase. getUserName → get_User_Name → get_user_name. Or just paste it into our text case converter and click snake_case.
Why is it called "camelCase"?
The uppercase letters in the middle of the word look like the humps of a camel: thisIsCamelCase. PascalCase is sometimes called "UpperCamelCase" because it's the same pattern with the first letter also capitalized.
Why is it called "kebab-case"?
The words look like they're skewered on a kebab stick: this-is-kebab-case. The hyphens are the skewer.
What is BEM naming in CSS?
BEM stands for Block, Element, Modifier. It extends kebab-case with double underscores and double hyphens: block__element--modifier. Example: card__title--highlighted. It's a methodology for organizing CSS class names in large projects.
Should database column names use snake_case?
In most databases, yes. SQL is case-insensitive by default, and snake_case is the widely accepted convention for table and column names (user_id, created_at, first_name). It also avoids quoting issues that arise with mixed-case names.
Does naming convention affect performance?
No. Naming conventions have zero effect on runtime performance. They exist entirely for human readability and tooling support.