A naming convention (case style) is the rule for how you mark word boundaries in a name made up of multiple words. userName, UserName, user_name, and user-name all mean the same thing, yet they look different and are used in different places. This article lays out, accurately, the definition and an example of each of camelCase / PascalCase / snake_case / SCREAMING_SNAKE_CASE / kebab-case / dot.case, the conventions per language and context, how to think about word boundaries when converting, lint tools for keeping things consistent, and common mistakes.
camelCase, classes and types use PascalCase, Python variables and functions use snake_case, constants use SCREAMING_SNAKE_CASE, and CSS classes and URLs use kebab-case.
1. Why naming conventions matter
Naming conventions are not just a matter of taste. In code written by a team, the more uniform the naming, the easier it is to read and the fewer mistakes occur. For example, if userName and user_name are mixed in the same file, the reader hesitates for a moment, wondering "is this a different variable?"
- Readability: word boundaries are clear at a glance, so you can grasp a name's meaning quickly.
- Consistency: when things of the same kind are written in the same style, search, replace, and autocompletion work more smoothly.
- Effect on behavior: in CSS classes, URLs, JSON keys, and more, a difference in case is treated as a different thing entirely (in most environments, case is significant). It is not merely a cosmetic issue.
- Language conventions: each language has a "standard style," and following it makes your code blend naturally with external libraries and your team's existing code.
In short, naming conventions concern both readability for humans and correctness for machines. First, let us nail down the exact form of each case.
2. Definition and example of each case
Here are the main case styles, compared using the same words (the three words "user profile id").
| Case | How boundaries are marked | Example (user profile id) |
|---|---|---|
| camelCase | First letter lowercase; capitalize the first letter of each subsequent word | userProfileId |
| PascalCase (UpperCamelCase) | Capitalize the first letter of every word (including the first) | UserProfileId |
| snake_case | All lowercase; separate words with underscores | user_profile_id |
| SCREAMING_SNAKE_CASE (CONSTANT_CASE) | All uppercase; separate words with underscores | USER_PROFILE_ID |
| kebab-case | All lowercase; separate words with hyphens | user-profile-id |
| dot.case | All lowercase; separate words with dots | user.profile.id |
- camelCase gets its name from the way the interior capital letters rise up like a camel's humps.
- PascalCase is camelCase with the first letter also capitalized, and it is also called UpperCamelCase.
- SCREAMING_SNAKE_CASE is snake_case in all uppercase; it is often used for constants and is also called
CONSTANT_CASE. - kebab-case is named after skewered kebab pieces and refers to the hyphen-joined style.
Hyphens and underscores look similar, but they can be used in different places. In many programming languages, a hyphen cannot be distinguished from the subtraction operator, so it cannot be used in identifiers. For that reason, kebab-case is used not for variable names in code but mainly in CSS, URLs, and file names.
3. Conventions per language and context
Even for the same "variable name," the standard case differs by language. Here are the representative conventions.
| Language / context | Variables / functions | Classes / types | Constants |
|---|---|---|---|
| JavaScript / TypeScript | camelCase | PascalCase | SCREAMING_SNAKE_CASE |
| Python (PEP 8) | snake_case | PascalCase | SCREAMING_SNAKE_CASE |
| Java / C# | camelCase * | PascalCase | SCREAMING_SNAKE_CASE ** |
| Go | camelCase (exported: PascalCase) | PascalCase | PascalCase / camelCase |
| Rust | snake_case | PascalCase | SCREAMING_SNAKE_CASE |
* C# has finer distinctions, such as PascalCase for methods and camelCase for local variables. ** Conventions vary by team and official guide; C#, for instance, recommends PascalCase for constants. When in doubt, it is safest to follow the language's official style guide (PEP 8 for Python, Effective Go for Go, and so on).
Outside of code, there are also standards per context.
- CSS class names:
kebab-caseis common (e.g.,.main-nav). Naming methodologies like BEM combine underscores and hyphens to express structure. - URL paths / file names:
kebab-caseis the standard (e.g.,/blog/naming-conventions-case-styles/). Sticking to lowercase prevents mistakes caused by mixing up case. - Constants: regardless of language,
SCREAMING_SNAKE_CASEis widely used (e.g.,MAX_RETRY_COUNT). - Environment variables: following shell conventions,
SCREAMING_SNAKE_CASEis standard (e.g.,DATABASE_URL,API_KEY). In POSIX shells, uppercase plus underscores is traditional, and hyphens cannot be used. - JSON keys: depending on the API, both
camelCaseandsnake_caseare possible. The important thing is not to mix them within a single API.
4. How to think about word boundaries when converting
When you convert from one case to another (with a tool or a function), the crux is correctly deciding "where the word boundaries are." Once you fix how you perceive the boundaries, all that remains is to apply the separator and the casing.
- snake_case / kebab-case have explicit boundaries. The positions of
_or-are the word boundaries as is. - camelCase / PascalCase have implicit boundaries; the basic rule is to treat the transition from lowercase to uppercase as a boundary. For
userProfile, it splits intouserandprofile.
The tricky part is handling consecutive uppercase letters (acronyms). In names like parseHTML or HTTPServer, where to split depends on the style.
HTTPServer into camelCase, the result differs depending on whether you produce httpServer or hTTPServer. The common approach—treating an acronym as a single word and lowercasing all but the first letter, as in httpServer / HttpServer—is more readable, and many style guides recommend it. When using an automatic conversion tool, being mindful of how acronyms are handled helps you avoid unexpected results.
In other words, the essence of conversion is to "break a name into a sequence of words and reassemble it in the target case." As long as you read the original case correctly, converting among camelCase ⇄ snake_case ⇄ kebab-case can be done mechanically.
5. Consistency and lint tools
Naming conventions are harder to "keep" than to decide. Relying on manual review alone leaves gaps, so the standard practice is to introduce a lint tool that checks automatically.
- ESLint (JavaScript / TypeScript): with the
camelcaserule or@typescript-eslint/naming-convention, you can enforce conventions such as camelCase for variables and PascalCase for types. - Pylint / flake8 (pep8-naming) (Python): inspects naming in line with PEP 8 (snake_case for functions, PascalCase for classes, and so on).
- gofmt / golint, clippy (Go / Rust): format and warn according to each language's standard style.
- EditorConfig and CI: built into format-on-save or automatic checks on pull requests, they reject convention violations before merge.
The key is to not merely write the convention in prose but to enforce it mechanically with tooling. That way, even when new members join, you keep consistency without having to point it out in review every time.
6. Common mistakes
Finally, here are the typical stumbling blocks around naming conventions.
- Ignoring the language's conventions: writing
userNamein Python out of JavaScript habit, for instance. It makes the reader speculate needlessly, "did they port this from another language?" - Mixing cases within a single project: when
user_idanduserIdcoexist in the same codebase, searchability drops and it becomes a breeding ground for bugs. - Underestimating case sensitivity: URLs, file names, and JSON keys are often case-sensitive, so
UserIdanduseridare treated as different things. In particular, developing on a case-insensitive file system and deploying to a case-sensitive server tends to cause breakage. - Using hyphens in identifiers: in many languages,
user-nameis interpreted as "user minus name" and cannot be used as a variable name. In code, use snake_case or camelCase. - Inconsistent acronym casing: when
userID,userId, anduseridare mixed, consistency falls apart. It is safest to settle on one for the project and lock it in with a linter.
Every one of these mistakes has the same root, and you can avoid them by being thorough about "matching conventions and staying consistent." When in doubt, follow the standard for your language and context, and enforce it with tooling.
Free Tool Convert for real with the Case Converter Convert any input string among camelCase, PascalCase, snake_case, kebab-case, and more, right in your browser. Handy for renaming and reworking names.Frequently Asked Questions (FAQ)
What is the difference between camelCase and PascalCase?
Both styles mark word boundaries with capital letters, but they treat the first letter differently. camelCase keeps the first letter lowercase and capitalizes only the first letter of each subsequent word (e.g., userName). PascalCase (also called UpperCamelCase) capitalizes the first word as well (e.g., UserName). In many languages, camelCase is used for variable and function names, while PascalCase is used for class and type names.
Which case is conventional in Python?
Python's official style guide, PEP 8, recommends snake_case for variables, functions, and modules, PascalCase (CapWords) for class names, and SCREAMING_SNAKE_CASE for constants. A common mismatch is for someone used to JavaScript's camelCase to write Python variables in camelCase, so follow the convention of the language your project uses.
Why is kebab-case so common in URLs?
In URL paths and file names, kebab-case, which uses hyphens to separate words, is preferred. There are several reasons. First, many servers and file systems are case-sensitive, so sticking to lowercase reduces mistakes. Second, underscores can be hard to see because they overlap with the underline of a link, and search engines have historically been said to treat hyphens as word separators more readily. For both readability and safety, kebab-case has become the standard.