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:
| camelCase | userAccountId |
|---|---|
| PascalCase | UserAccountId |
| snake_case | user_account_id |
| CONSTANT_CASE | USER_ACCOUNT_ID |
| kebab-case | user-account-id |
| dot.case | user.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 format | camelCase for | Other styles |
|---|---|---|
| JavaScript and TypeScript | variables, functions, object properties | PascalCase for classes and components |
| Java | variables, methods | PascalCase for classes, CONSTANT_CASE for constants |
| C# | local variables, parameters | PascalCase for methods, properties and classes |
| Go | unexported (private) names | PascalCase for exported names |
| Swift and Kotlin | variables, functions, properties | PascalCase for types |
| JSON APIs | keys in many APIs (createdAt) | some APIs use snake_case |
| Python | rarely | snake_case for variables and functions (PEP 8) |
| CSS and URLs | not used | kebab-case |
camelCase rules and tips
- Start with a lowercase letter:
userName, notUserName, 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, notloadHTTPURL. 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.