What is Camel Case?

What Camel Case is, its history and variations, uses in programming and human languages, and benefits as an accessibility and SEO strategy.
On this page

What is Camel Case?

Camel case, also known as camel caps or more formally as medial capitals, refers to the practice of writing compound words or phrases by concatenating the words, capitalizing the first letter of each word, and removing spaces between the words. The name comes from the capital letter bumps resembling the humps of a camel. While there are a few variations, camel case is commonly used in programming languages, webpage URLs, wiki links, and to create acronyms or initialisms from existing phrases.

A Brief History of Camel Case

The exact origins of the term “camel case” are unclear, but it became popular in programming languages starting in the 1970s and 80s. The earliest known usage was in 1995 by NewtonScript programming language creator Walter Smith. One theory speculates that the camel bumps resemble the upper humps on a Bactrian camel, which has two humps rather than one. Despite the whimsical name, camel case serves important technical purposes in various fields.

Variations of Camel Case

There are a few common variations on the capitalization of camel case (Naming convention):

Lower Camel Case

This version capitalizes all words except the first. For example, lowerCamelCase. It is commonly used for variable and method names in programming languages like Java, JavaScript, and C#.

Upper Camel Case

Also known as Pascal case, this version capitalizes the first letter of every word. For example, UpperCamelCase. It is often used for class names and constants in programming.

Capital Camel Case

This less common version capitalizes every letter. For example, CAPITALCAMELCASE. It can sometimes be used for constants or namespaces.

Hyphenated Camel Case

Some variations use hyphens in between the words instead of concatenating them. For example, lower-CamelCase or Upper-CamelCase.

Kebab Case

In kebab case, words are lowercased and separated with hyphens, like kebab-case or html-parser.

Snake Case

Snake case uses underscores instead of hyphens, like html_parser or variable_name.

Uses of Camel Case in Human Languages

Outside of programming, camel case appears in natural languages as well. Some examples include:

  • Transliterations of names from foreign alphabets, like the name Mu’ammar Gaddafi.

  • Creative misspellings for emphasis, like Craaazy or Amaaaaazing.

  • Abbreviations built from initials, like SQLServer or iTunes.

  • Compound words formed by concatenation, like CarPark or WebSite.

Using camel caps helps fuse compound words and names into cohesive units that are easy to read.

Camel Case in Computer Programming

One of the most common uses of camel case is as a naming convention in computer programming languages. For example:

  • lowerCamelCase for variables and methods
  • UpperCamelCase for classes
  • CAPITAL_SNAKE_CASE for constants (SCREAMING_SNAKE_CASE)

The capitalization helps distinguish different types of code elements from each other and improves readability. Spaces are omitted because most programming languages do not allow spaces in names. Camel case became popular in C-style languages like C++, Java, JavaScript, and C# and is a de facto standard convention.

Converting Between Styles

You can use online tools to easily convert strings between different naming styles:

Benefits of Using Camel Case

Using camel case offers several advantages:

Improved Accessibility

Proper noun capitalization improves accessibility for people using screen readers or those with visual impairments. For example, the hashtag #healthcareisahumanright is easier to parse when written as #HealthcareIsAHumanRight. This helps more people access and engage with the content.

Optimized SEO

Camel case can improve SEO and visibility when used in titles and headings. Capital letters help search engines parse individual words, making it easier to rank for those keywords.

Avoids Misunderstandings

Lowercase phrases can sometimes be misread. #handsoffvenezuela could be misinterpreted as hands-off Venezuela instead of hands off Venezuela. Camel case like #HandsOffVenezuela helps avoid such confusion.

Proper Use of Camel Case

When using camel case, here are some guidelines to follow:

  • Capitalize the first letter of every word, except the first word in lower camel case.

  • Omit spaces between words and concatenate them into one unit.

  • Use logical word breaks that enhance readability. Don’t concatenate words that should stand alone.

  • Use upper camel case for class names, constants, and branding. Use lower camel case for variables, methods, and function names.

  • Maintain consistency throughout your codebase or writing. Don’t mix styles arbitrarily.

Some common mistakes to avoid:

  • Random capitalization like CrazYcasE or miXeDcAsE. This harms readability.

  • Over-concatenation into lengthy strings without word breaks.

  • Inconsistently switching between styles without reason.

Camel Case vs Other Naming Conventions

Camel case is not the only naming convention used in computing. Others include:

Snake Case

Snake case uses underscores to separate words instead of camel bumps, like variable_name or HTML_parser. It is commonly used in Python, Ruby, and some Linux programs.

PascalCase

Pascal case is an upper camel case convention popularly used for class names in programming languages like Java, JavaScript, and C#.

Camel case and PascalCase follow the same capitalization rules. The difference is PascalCase is always upper case, while camel case can be lower or upper.

Conclusion

In summary, camel case is a widely used convention for joining words without spaces and capitalizing each word. While the amusing name comes from the capital letter humps resembling a camel’s back, camel case serves important technical purposes. It improves accessibility for impaired users, optimizes SEO, brands memorable names, and enhances readability of code. By properly using lower or upper camel case and avoiding common mistakes, you can take full advantage of this popular naming convention.