Developer

Naming Conventions and Case Styles: camelCase vs snake_case vs kebab-case

How readable your code is depends heavily on how you name variables and functions. This article explains the differences between the main case styles—camelCase, snake_case, kebab-case, PascalCase, and CONSTANT_CASE—the conventions in languages such as JavaScript, Python, and CSS, and how to choose for variables, functions, constants, and file names, in a way beginners can follow.

Published: 2026-10-16

Even for the same meaning of "user name," code can write it many ways: userName, user_name, user-name, or UserName. Which one you pick is not a matter of taste—it is largely fixed by the naming convention (case style) of each language. This article explains the differences between the case styles and what to use where, step by step.

What Naming Conventions and Case Styles Are

A naming convention is the overall set of rules for naming variables, functions, classes, files, and so on. Within that, case (style) refers specifically to how you separate multiple words and apply upper- or lowercase when joining them into a single name. For example, the way you combine the two words "user" and "name" into one name is exactly what the difference in case is about.

Why do naming conventions matter? Because code is not "written once and done"—it is read again and again and changed by multiple people. If naming is inconsistent, the reader has to keep re-deciding "is this a variable, a class, or a constant?", which adds needless mental load. The consistency of writing the same kind of thing in the same style is the foundation of readability and maintainability.

Most programming languages and frameworks define recommended naming conventions in a style guide. The rule of thumb is to follow the language's standard first, rather than your personal preference.

The Five Main Case Styles and Their Differences

Five case styles appear most often in practice. Lining them up with the same two words, "user" and "name," makes the differences obvious at a glance.

Case styleExampleHow it separates words
camelCaseuserNameLowercase first; capitalize each later word
PascalCaseUserNameCapitalize the first letter of every word
snake_caseuser_nameSeparate with underscores, all lowercase
kebab-caseuser-nameSeparate with hyphens, all lowercase
CONSTANT_CASEUSER_NAMEUnderscore-separated, all uppercase

camelCase is named for the "humps" of a camel formed by the rising mid-word capitals. It starts lowercase and capitalizes only the first letter of each later word. It is widely used for variable and function names.

PascalCase capitalizes the first letter of every word. Also called upper camel case, it is commonly used for class names, type names, and component names.

snake_case joins words with underscores (_) and keeps everything lowercase. The name comes from its low, connected look, like a snake on the ground. It is the standard for Python variables and functions and for database column names.

kebab-case separates words with hyphens (-). The name is said to come from items skewered on a kebab. It is common in URLs, CSS class names, and file names.

CONSTANT_CASE uses all uppercase with underscore separators. Also called screaming snake case, it is used for constants that represent unchanging values.

Per-Language Conventions: JS, Python, CSS

Which case to use is largely set by each language's culture. Knowing the conventions of a few representative languages greatly reduces hesitation.

Rule of thumb: follow the language's style guide. Prefer consistency over personal style.

JavaScript / TypeScript

Variables and functions use camelCase, classes, types, and React components use PascalCase, and constants use CONSTANT_CASE. For example: getUserName() (function), class UserProfile (class), and const MAX_RETRY = 3 (constant).

Python

The standard style guide PEP 8 specifies snake_case for variables and functions, PascalCase for classes, and CONSTANT_CASE for constants. So you get get_user_name(), class UserProfile, and MAX_RETRY = 3—note that the function name differs from JavaScript.

CSS / HTML / URL

For CSS class names, HTML attributes, and URL paths, kebab-case is the standard: .user-profile or /blog-posts/, joined with lowercase and hyphens. Hyphens are often preferred over underscores in URLs because search engines are said to recognize them more readily as word separators.

If you are unsure how to convert between these styles, entering text into the Naming Case Converter and comparing the results converted into each case makes it quick to understand.

Choosing for Variables, Functions, Constants, and File Names

Even within one language, the case you use changes depending on whether the target is a variable, a class, or a constant. Here is a typical way to choose.

  • Variables and functions: follow the language standard (camelCase in JS, snake_case in Python). Choose nouns and verbs that convey the role.
  • Classes, types, components: PascalCase in most languages. A leading capital makes it clear at a glance that this is a type, not an instance.
  • Constants: use CONSTANT_CASE for unchanging values. The prominent uppercase tells readers "this is a fixed value."
  • File names and URLs: kebab-case is the safe choice, less prone to environment-related accidents. It also avoids problems with case-insensitive operating systems.

File names in particular can cause unexpected bugs when case-sensitive operating systems (Linux) and case-insensitive ones (some Windows or macOS settings) are mixed. Standardizing on all lowercase plus hyphens is safer. When you build the trailing part of an article or product URL (the slug), the Slug Generator lets you quickly create readable kebab-case URLs, even from a non-English title.

Tips for More Readable Names

Beyond choosing the right case, the quality of the name itself greatly affects readability. Just keeping the following in mind makes code much easier to read.

  • Do not over-abbreviate: prefer userName over usrNm. Even if a bit longer, favor names whose meaning is clear.
  • Be consistent: do not mix userName and user_name in one project. Write the same concept the same way.
  • Phrase booleans as questions: use names answerable by true/false, like isActive or hasError.
  • Distinguish singular and plural: user for one, users for an array. Let the name express quantity.

There is rarely a single "correct" name, but the most important thing is that everyone follows the rules the team or project has agreed on. Uniform consistency makes the whole codebase more readable than brilliant individual choices.

Converting Cases and Avoiding Inconsistency

In practice, existing code or external API data often arrives in a different case than your project uses. For example, an API returns user_name, but you want to standardize on camelCase in the frontend. Rewriting each one by hand tends to introduce inconsistencies and typos.

The key to conversion is to first break a name into a "sequence of words," then reassemble it in the target case. snake_case and kebab-case have clear separators and are easy to split, while camelCase and PascalCase read the position of capitals as the separators. Since doing this by hand is tedious, when you want to convert in bulk, the surest approach is to paste the string into the Naming Case Converter and convert it at once into multiple forms such as camelCase, snake_case, and kebab-case. If you only need a URL slug, the Slug Generator is faster, so use them according to your goal.

Naming conventions are a foundational skill you can use for a lifetime once learned. Start by grasping the broad rules—"variables follow the language standard," "classes use PascalCase," "constants use CONSTANT_CASE," "URLs and files use kebab-case"—and when in doubt, compare with a converter tool until they become second nature.

Please note that this article is intended to provide general information. Recommended styles for each language and framework can change, so make your decision after checking the latest official style guides and your team's conventions.

FAQ

How do I choose between camelCase and snake_case?

It is set by language convention. In JavaScript and TypeScript, variables and functions use camelCase (userName); in Python they use snake_case (user_name). Follow the style guide of the language you use first, and above all keep a consistent style within your project.

When should I use PascalCase?

PascalCase (UserProfile), which capitalizes the first letter of every word, is used in many languages for class names, type names, and components such as in React. The leading capital makes it easy to tell at a glance that something is a type or class rather than an instance.

How should I name constants?

For constants that represent unchanging values, it is common to use CONSTANT_CASE (MAX_RETRY, API_BASE_URL): all uppercase with underscore separators. The prominent uppercase quickly tells readers "this is a fixed value" and helps prevent accidental changes.

Which case is best for URLs and file names?

kebab-case (user-profile) is the standard for URL paths, CSS classes, and file names. Using all lowercase and hyphens avoids bugs that arise between case-sensitive and case-insensitive operating systems, and in URLs the word separators are recognized more readily.

Is the text I enter into the case converter sent to a server?

WAZA TOOLS' Naming Case Converter and Slug Generator run entirely in your browser, so the text you enter is never sent to or stored on a server. They work on smartphones too, and you can convert as many times as you like, for free.