TC
ProgrammingJanuary 16, 2025·4 min read

What is Camel Case? Definition, Examples & Uses in Code

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

LanguageWhat Uses camelCase

|---|---|

JavaScriptVariables, functions, object properties, methods
TypeScriptSame as JavaScript
JavaVariables, methods, parameters
KotlinVariables, functions, properties
SwiftVariables, functions, constants
C#Local variables, parameters (methods use PascalCase)
JSONAPI response keys (e.g., `{"userId": 42}`)
CSS-in-JSStyled 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:

AspectcamelCasePascalCase

|---|---|---|

First letterLowercaseUppercase
Example`myFunction``MyFunction`
Used forVariables, functionsClasses, types, React components
Also calledlowerCamelCaseUpperCamelCase

Tips for Using camelCase

  • Acronyms: Most style guides recommend treating acronyms as one word — parseHtml not parseHTML; xmlParser not XMLParser
  • Numbers: Treat leading numbers as words — row2Col, not row2col
  • Consistency: Pick a convention for acronyms and stick to it within your project