What Is camelCase in Programming?

camelCase is a way of writing several words as one name: no spaces, the first word in lowercase, and every following word starting with a capital letter, like firstName or totalPrice.

Last updated:

camelCase in one sentence

Write the words together, keep the first one lowercase, and capitalize the first letter of every word after it: “first name” becomes firstName, “is user logged in” becomes isUserLoggedIn.

The name comes from the capital letters in the middle, which stick up like the humps of a camel. It's also called lower camel case or dromedary case.

camelCase compared with other naming styles

Programming names can't contain spaces, so each language community picked a style to join words. Here is the same phrase in each one, converted by our tool:

Before user account id
camelCaseuserAccountId
PascalCaseUserAccountId
snake_caseuser_account_id
CONSTANT_CASEUSER_ACCOUNT_ID
kebab-caseuser-account-id
dot.caseuser.account.id

camelCase vs PascalCase

The only difference is the first letter. camelCase starts lowercase (userAccount); PascalCase starts with a capital (UserAccount). PascalCase is sometimes called upper camel case.

In most languages that use both, camelCase names variables and functions, while PascalCase names classes and types: const userAccount = new UserAccount().

Where camelCase is used

Language or formatcamelCase forOther styles
JavaScript and TypeScriptvariables, functions, object propertiesPascalCase for classes and components
Javavariables, methodsPascalCase for classes, CONSTANT_CASE for constants
C#local variables, parametersPascalCase for methods, properties and classes
Gounexported (private) namesPascalCase for exported names
Swift and Kotlinvariables, functions, propertiesPascalCase for types
JSON APIskeys in many APIs (createdAt)some APIs use snake_case
Pythonrarelysnake_case for variables and functions (PEP 8)
CSS and URLsnot usedkebab-case

camelCase rules and tips

  • Start with a lowercase letter: userName, not UserName, which would be PascalCase.
  • No spaces, hyphens or underscores between words.
  • Acronyms: many style guides, including Google's Java and JavaScript guides, treat them as normal words: loadHttpUrl, not loadHTTPURL. It's easier to read, especially when two acronyms meet.
  • Numbers can go inside or at the end (version2, utf8Encoder) but never at the start, because most languages don't allow a name to begin with a digit.
  • Be consistent: follow the style your language, framework or team already uses.

How to convert text to camelCase

Paste any phrase into our camelCase converter and it removes the spaces and capitals for you, even from messy input like User-Account_ID. Need a different style? Use the snake_case converter for Python and databases, the kebab-case converter for CSS, or the slug generator for URLs.

Frequently asked questions

Why is it called camelCase?

Because the capital letters in the middle of the word, like the B in myBook, stick up like the humps on a camel's back.

What is the difference between camelCase and PascalCase?

Only the first letter. camelCase starts lowercase (myVariable); PascalCase starts uppercase (MyVariable). In many languages camelCase is for variables and functions, PascalCase for classes.

Is camelCase or snake_case better?

Neither is better in general: use the convention of your language. JavaScript, Java and Swift use camelCase; Python and Ruby use snake_case for variables and functions. Mixing styles in one codebase is the real problem.

How do you write acronyms in camelCase?

Most modern style guides capitalize only the first letter of an acronym, as if it were a normal word: userId, parseHtml, XmlHttpRequest. Some older code keeps acronyms in capitals (userID). Pick one and use it consistently.

Is camelCase case-sensitive?

In case-sensitive languages like JavaScript, Java and C#, yes: userName and username are two different names. That's why consistent naming matters.