What is CamelCase? A Developer's Complete Guide

CamelCase is everywhere in programming — but so are its relatives PascalCase, snake_case, and kebab-case. This guide explains each convention, which languages use them, and when to use which.

What is CamelCase?

CamelCase (also written camel case or camelCase) is a naming convention where multiple words are concatenated without spaces, and each word except the first starts with a capital letter. The name comes from the "humps" formed by the capital letters — like a camel's back.

Examples: myVariable, getUserData, firstName, isLoggedIn

Types of CamelCase

There are two variants of camelCase in widespread use:

Lower camelCase (camelCase)

The first word is entirely lowercase; each subsequent word starts with a capital letter. This is what most developers mean when they say "camelCase".

Used for: variables, functions, and method names in JavaScript, Java, Swift, Kotlin, TypeScript, and C#.

Upper CamelCase (PascalCase)

Every word, including the first, starts with a capital letter. Also called PascalCase because it was popularized by the Pascal programming language.

Used for: class names, constructor functions, React components, C# namespaces, and TypeScript interfaces.

CamelCase vs snake_case

snake_case uses all lowercase letters with underscores separating words. It is the opposite approach to camelCase's capitalization strategy.

ConceptcamelCasesnake_case
User ID variableuserIduser_id
Get user functiongetUser()get_user()
Is valid flagisValidis_valid
First name fieldfirstNamefirst_name

Use camelCase in: JavaScript, TypeScript, Java, Swift, Kotlin, C#

Use snake_case in: Python, Ruby, PHP (variables), SQL column names, file names in many projects

CamelCase vs kebab-case

kebab-case (also called spinal-case or hyphen-case) uses all lowercase words joined by hyphens. It is named for the resemblance to food on a skewer.

ConceptcamelCasekebab-case
CSS class(not used)user-profile-card
URL slug(not used)getting-started-guide
File nameuserProfile.jsuser-profile.js
HTML attributedata-userIddata-user-id

Important: Kebab-case cannot be used as variable names in most programming languages because the hyphen is treated as a subtraction operator. It is primarily used in CSS, HTML, URLs, and file names.

All Four Naming Conventions Compared

ConventionExampleWhere used
camelCasegetUserDataJS/TS variables & functions, Java, Swift
PascalCaseGetUserDataClasses, React components, C# methods
snake_caseget_user_dataPython, Ruby, SQL, PHP variables
kebab-caseget-user-dataCSS, HTML, URLs, file names
SCREAMING_SNAKE_CASEMAX_RETRY_COUNTConstants in most languages

When to Use CamelCase: Language-by-Language Guide

Why Consistent Naming Conventions Matter

Consistent naming conventions make code easier to read, search, and maintain. When every developer on a team follows the same convention, there is no ambiguity about whether a function should be called getUser, get_user, or GetUser. Most linters and formatters (ESLint, Prettier, Black, RuboCop) can automatically enforce naming conventions as part of your CI/CD pipeline.

Need to convert text between naming conventions? Try our Case Modify tools — including uppercase, lowercase, and text transformation tools that work directly in your browser.

Frequently Asked Questions

What is camelCase in programming?

CamelCase is a naming convention where words are joined without spaces, and each word after the first starts with a capital letter: myVariableName. It is one of the most widely used naming conventions in JavaScript, Java, Swift, and TypeScript.

What is the difference between camelCase and PascalCase?

In camelCase the first word is lowercase (myClass); in PascalCase every word starts with a capital (MyClass). PascalCase is typically used for class names; camelCase for variables and functions.

Should I use camelCase or snake_case for JavaScript?

The JavaScript community convention (and the ECMAScript specification) uses camelCase for variables and functions. Use camelCase in JavaScript and TypeScript projects unless your team's style guide specifies otherwise.

Can I use camelCase in CSS?

Technically yes, but it is strongly discouraged. CSS convention is kebab-case for class names and IDs (.user-profile-card). HTML attributes and custom data attributes also use kebab-case (data-user-id). CamelCase in CSS can cause confusion and break cross-browser compatibility in some edge cases.

Related articles: What is Title Case?Uppercase vs LowercaseWhat is Sentence Case?