What Is Camel Case? Definition & Examples

Camel case is a naming convention for naming objects with compound words in programming. Here are some examples of the camel case:

  1. myAge
  2. mainViewController
  3. defaultUserParameters

Camel case works such that:

  • The very first letter is not capitalized.
  • The first letters of each compound word are capitalized.

What Problem Does Camel Case Solve?

To write software at scale, one has to write readable and understandable code. One way to make code easy to understand is to use logical names with objects, such as variables, classes, and functions. And to be descriptive, you usually need to combine multiple words in a single name.

This makes multi-word names look something like this: nearbydevicesviewcontroller.

The reason why there are no white spaces in this name is that programming languages don’t allow using spaces between words.

This makes multi-word names hard to read. This is where case styles help. A popular letter casing system is known as the camel case.

In the camel case, the idea is to make each compound word start with a capital letter, except for the first letter in the word combination. The camel case makes it easier to read multi-word object names as each word is distinguishable thanks to the capital letters. For example, let’s convert the previously mentioned 4-word object into the camel case:

  • nearbydevicesviewcontroller –> nearbyDevicesViewController

Now the word combination is much easier to read.

Why Is It Called the Camel Case?

The reason why the camel case has such a funky name requires a bit of imagination. In a sense, compound words in camel case look like the bumps on the back of a camel. Here is an illustration I drew to make it more clear:

Here is the reason why it’s called the camel case…

Other Case Systems

Camel case is not the only case style out there. To be precise, there are four case styles commonly used in software development. These styles are:

  1. Pascal Case
  2. Camel Case
  3. Snake Case
  4. Kebab Case

Let’s take a brief look at each case style.

1. Pascal Case (PascalCase)

Pascal case is similar to Camel case. The difference is in the very first letter of a multi-word combination.

  • In Pascal case, the first letter is also capitalized.
  • In Camel case, the very first letter is not capitalized.

For instance, here is a variable with a name in the Pascal case:

MyBankBalance = 1000

Pascal case originates from the Pascal programming language. The community started capitalizing on first letters to make the code readable.

The idea spread to other languages.

Pascal case and camel case are both equally common naming conventions in the coding landscape. The case style you should use depends on your team, coding language, and personal preferences.

2. Snake Case (snake_case)

Snake case is another popular case style. Unlike the camel case or Pascal case, the snake case doesn’t use capital letters. Instead, the words are separated by underscores.

For instance:

my_bank_balance = 100

Usually, the snake case is useful for declaring constants. In this case, all the letters are typically capitalized too.

PI_APPROX = 3.14159

Another popular use case for the snake case is in databases.

    username: "Alice",
    user_login_attempts: 13,
    last_attempt: 1662988728,

3. Kebab Case (kebab-case)

A less common, yet still popular case style is the kebab case. The kebab case is reminiscent of the snake case. But instead of using underscores, the words are separated by dashes.

For example:

my-bank-balance = 101

Most programming languages don’t support using a dash as a separator. This makes using the kebab case impossible in many languages.

You typically see the kebab case take place in URL slugs.

For example:


The Kebab case makes the URL slugs more readable.

Wrap Up

Today you learned what is the camel case in programming.

To take home, the camel case is a naming convention to keep code as readable as possible. In the camel case, each compound word starts with a lowercase first letter except for the very first letter of the first word.

The reason why you use case styles is important is that you cannot use blank spaces in coding languages. Different case styles help make the distinction for the eyes easier.

Instead of separating the words with spaces, the case style uses a different separator mechanism. One of the most popular examples is the camel case where the first letters are capitalized.

In addition to the camel case, other popular case styles include:

  • Pascal case (camelCase)
  • Snake case (snake_case)
  • Kebab case (kebab-case)

All the case styles serve the same purpose: make code readable when spaces can’t be used.

Thanks for reading. Happy coding!

Scroll to Top