HomeBlogText Tools Guide › camelCase vs snake_case vs kebab-case
Text Tools April 14, 2026 8 min read

camelCase vs snake_case vs kebab-case: When to Use Each

Understanding camelCase vs snake_case vs kebab-case is essential for any developer or technical writer. Each naming convention has specific use cases across different programming languages, frameworks, and contexts. In this guide, we explain the differences and exactly when to use camelCase vs snake_case vs kebab-case.

What are naming conventions?

Naming conventions are rules for formatting multi-word identifiers in code. Because most programming languages do not allow spaces in variable names, function names, or class names, developers use naming conventions to combine multiple words into a single readable identifier.

For example, the phrase "user first name" cannot be used as a variable name with spaces. Instead, developers write it as userFirstName (camelCase), user_first_name (snake_case), or user-first-name (kebab-case) depending on the language and context.

Furthermore, following consistent naming conventions within a codebase makes code significantly more readable and maintainable. As a result, most programming languages and frameworks have established conventions that developers are expected to follow.

Key point

There is no universally "correct" naming convention — the right choice depends entirely on the programming language, framework, and context you are working in. The most important thing is consistency within a project.

camelCase — the JavaScript standard

camelCase joins words without spaces, capitalising every word except the first. The name comes from the "humps" created by the capital letters in the middle of the word — like a camel's back.

camelCase
helloWorld / userFirstName / getApiResponse
Starts with a lowercase letter. Every subsequent word starts with an uppercase letter. No spaces or separators between words.
Used in: JavaScript variables and functions, Java variables, Swift variables, TypeScript, JSON keys, React props

When to use camelCase

  • JavaScript variablesconst userName = "John"
  • JavaScript functionsfunction getUserData()
  • JSON object keys{"firstName": "John"}
  • React component props<Button onClick={handleClick}>
  • Java and Swift variables — standard in both languages

PascalCase — for classes and components

PascalCase is similar to camelCase but capitalises every word including the first. It is sometimes called "UpperCamelCase" for this reason.

PascalCase
HelloWorld / UserProfile / ApiResponse
Every word starts with an uppercase letter including the first word. No spaces or separators between words.
Used in: Class names in most languages, React components, TypeScript interfaces, C# variables, constructor functions

When to use PascalCase

  • Class namesclass UserProfile {} in JavaScript, Python, Java
  • React componentsfunction NavBar(), function UserCard()
  • TypeScript interfaces and typesinterface UserData {}
  • C# variables and methods — PascalCase is the standard for all C# identifiers

snake_case — the Python standard

snake_case uses underscores to separate words, with all letters in lowercase. The name comes from the flat, horizontal appearance — like a snake lying on the ground.

snake_case
hello_world / user_first_name / get_api_response
All lowercase letters with underscores between words. No spaces or capital letters. Highly readable because the underscores visually separate words clearly.
Used in: Python variables and functions, Ruby variables, database column names, PostgreSQL, file names in Unix/Linux systems

When to use snake_case

  • Python variables and functionsuser_name = "John", def get_user_data():
  • Database column namesfirst_name, created_at, user_id
  • Ruby methods and variables — snake_case is the Ruby standard
  • File namesmy_script.py, user_profile.rb
  • PostgreSQL and MySQL column names — databases conventionally use snake_case
Python PEP 8 tip

Python's official style guide (PEP 8) specifies snake_case for all variable names, function names, and module names. Following this convention makes your Python code consistent with the broader Python ecosystem and easier for other developers to read.

kebab-case — the CSS and URL standard

kebab-case uses hyphens to separate words, with all letters in lowercase. The name comes from the appearance of words "skewered" together by hyphens — like food on a kebab skewer.

kebab-case
hello-world / user-first-name / get-api-response
All lowercase letters with hyphens between words. Cannot be used in most programming languages as variable names because hyphens are interpreted as minus operators. However, it is the standard for CSS, HTML, and URLs.
Used in: CSS class names, HTML attributes, URL slugs, CLI commands, Vue.js components, HTTP headers

When to use kebab-case

  • CSS class names.nav-bar, .user-profile, .hero-section
  • HTML attributesdata-user-id, aria-label
  • URL slugs/how-to-use-case-converter, /best-image-format
  • CLI commands and flags--output-file, --dry-run
  • Vue.js component names<user-profile>, <nav-bar>
  • HTTP headersContent-Type, Accept-Encoding

CONSTANT_CASE — for fixed values

CONSTANT_CASE uses all uppercase letters with underscores between words. It is used specifically for constants — values that never change during program execution.

CONSTANT_CASE
MAX_RETRIES / API_BASE_URL / DEFAULT_TIMEOUT
All uppercase letters with underscores between words. The all-caps appearance immediately signals to other developers that this value is a constant that should not be reassigned.
Used in: Constants in JavaScript, Python, Java, C/C++, environment variables, configuration values

Quick reference — camelCase vs snake_case vs kebab-case

Here is a practical summary of when to use camelCase vs snake_case vs kebab-case in different contexts:

  • JavaScript variables and functions → camelCase
  • JavaScript/TypeScript classes and React components → PascalCase
  • Python variables, functions, and files → snake_case
  • Database column names → snake_case
  • CSS class names and HTML attributes → kebab-case
  • URL slugs and page paths → kebab-case
  • Constants and environment variables → CONSTANT_CASE
  • JSON keys in REST APIs → camelCase (most common) or snake_case
Important

When working with a team or an existing codebase, always follow the existing convention — even if it differs from what you personally prefer. Consistency within a project is more important than following any particular convention.

How to convert between cases instantly

Manually converting text between camelCase, snake_case, and kebab-case is tedious and error-prone, especially for long identifiers. Our free case converter handles all conversions instantly — paste your text, click the target case, and copy the result.

In addition to camelCase, snake_case, and kebab-case, our tool also supports PascalCase, CONSTANT_CASE, dot.case, UPPERCASE, lowercase, Title Case, Sentence case, and two creative case formats. As a result, you can convert between any naming convention in one click.

Convert text case instantly — free

camelCase, snake_case, kebab-case and 9 more formats

Convert case →

Frequently asked questions

Is camelCase or snake_case more readable?

Research on code readability suggests that snake_case is marginally more readable for most people because the underscore character creates a clear visual separation between words. However, camelCase is faster to type and is the dominant convention in JavaScript and many other popular languages. In practice, readability depends more on familiarity — developers tend to find the convention they use most to be the most readable.

Can I use camelCase in Python?

Python allows camelCase syntactically, but it is strongly discouraged. Python's official style guide PEP 8 specifies snake_case for variables and functions. Furthermore, the Python standard library and most Python packages use snake_case consistently. As a result, using camelCase in Python makes your code look out of place and harder for other Python developers to read.

Why can't I use kebab-case in JavaScript?

kebab-case cannot be used for JavaScript variable or function names because the hyphen character is interpreted as the minus operator. For example, user-name would be parsed as user minus name, which is a subtraction expression rather than a variable name. This is why JavaScript uses camelCase instead.

What naming convention do REST APIs use?

REST APIs most commonly use either camelCase or snake_case for JSON keys, depending on the team's preference and the primary programming language of the backend. JavaScript-based APIs tend to use camelCase, while Python and Ruby APIs often use snake_case. Furthermore, URL paths in REST APIs almost always use kebab-case slugs.

Related articles

Scroll to Top