What is Camel Case?
camelCase is a naming convention where words are joined without spaces, with each word (except the first) starting with a capital letter. The pattern resembles the humps of a camel.
Examples: firstName, getUserById, backgroundColor, parseJsonResponse
Types of Camel Case
There are two main variants:
lowerCamelCase (standard camelCase)
The first word is entirely lowercase; subsequent words are capitalized.
myVariable,getUserName,totalPrice
UpperCamelCase (PascalCase)
Every word, including the first, starts with a capital letter.
MyVariable,GetUserName,TotalPrice
Where camelCase is Used
| Language | What Uses camelCase |
|---|
|---|---|
| JavaScript | Variables, functions, object properties, methods |
|---|---|
| TypeScript | Same as JavaScript |
| Java | Variables, methods, parameters |
| Kotlin | Variables, functions, properties |
| Swift | Variables, functions, constants |
| C# | Local variables, parameters (methods use PascalCase) |
| JSON | API response keys (e.g., `{"userId": 42}`) |
| CSS-in-JS | Styled component props (`backgroundColor`) |
Origin of camelCase
The term "camelCase" was popularized in the 1990s, though the convention itself is older. It became dominant in Object-Oriented Programming because of its readability in languages like C++ and Java.
camelCase vs PascalCase
Many developers confuse these two:
| Aspect | camelCase | PascalCase |
|---|
|---|---|---|
| First letter | Lowercase | Uppercase |
|---|---|---|
| Example | `myFunction` | `MyFunction` |
| Used for | Variables, functions | Classes, types, React components |
| Also called | lowerCamelCase | UpperCamelCase |
Tips for Using camelCase
- Acronyms: Most style guides recommend treating acronyms as one word —
parseHtmlnotparseHTML;xmlParsernotXMLParser - Numbers: Treat leading numbers as words —
row2Col, notrow2col - Consistency: Pick a convention for acronyms and stick to it within your project