Naming Conventions and Case Styles — camelCase, snake_case, kebab-case, PascalCase

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.

The bottom line first: there is no absolute right answer for case; what matters most is to match the convention of the language and context you are working in and stay consistent. As a rule of thumb, JavaScript variables and functions use 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?"

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").

CaseHow boundaries are markedExample (user profile id)
camelCaseFirst letter lowercase; capitalize the first letter of each subsequent worduserProfileId
PascalCase
(UpperCamelCase)
Capitalize the first letter of every word (including the first)UserProfileId
snake_caseAll lowercase; separate words with underscoresuser_profile_id
SCREAMING_SNAKE_CASE
(CONSTANT_CASE)
All uppercase; separate words with underscoresUSER_PROFILE_ID
kebab-caseAll lowercase; separate words with hyphensuser-profile-id
dot.caseAll lowercase; separate words with dotsuser.profile.id

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 / contextVariables / functionsClasses / typesConstants
JavaScript / TypeScriptcamelCasePascalCaseSCREAMING_SNAKE_CASE
Python (PEP 8)snake_casePascalCaseSCREAMING_SNAKE_CASE
Java / C#camelCase *PascalCaseSCREAMING_SNAKE_CASE **
GocamelCase (exported: PascalCase)PascalCasePascalCase / camelCase
Rustsnake_casePascalCaseSCREAMING_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.

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.

The tricky part is handling consecutive uppercase letters (acronyms). In names like parseHTML or HTTPServer, where to split depends on the style.

Watch out for acronyms. For example, when turning 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.

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.

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.

← Back to the Tech Blog list