Camel and Snake Case Converter

What is Camel Case?

Camel case is the practice of capitalizing the first letter of each word in a series and then removing spaces, numbers, underscores, hyphens, and other special characters. This leaves a concatenation of words that is combined into a single string with various letters capitalized throughout. Camel case is often used in programming using the lower camel case method where the first letter of the string is lowercased. Upper camel case, also known as pascal case, is the most common form in everyday usage while lower camel case is primarily used for programming.

Basic Camel Case Capitalization Rules

  • The first letter is capitalized.
  • One or more letters in that word are also capitalised.
  • The word does not end on a capitalized letter: CamelCasE
  • No two capitalised letters shall follow directly each other: CamelCAse
  • No number in that word at any place: CamelCase1more
  • No dot(.), under_score or dash (-) within the word, only letters: Camel_Case
  • No ‘foreign’ letters in it like äöüß or accentuated like áéí. CämélCáße

Camel Case Examples

Upper Camel Case / Pascal Case

  • ThisIsAnExampleOfTheUpperCamelCaseForm
  • TheFirstLetterIsCapitalizedAndEachWordThroughoutIsAsWell

Lower Camel Case

  • theFirstLetterIsNotCapitalizedAndEachWordThroughoutIs
  • thereAreNoHyphensOrSpacesInThisCamelCase

 

What is the difference between Pascal Case and Camel Case?

Pascal Case is a subset of Camel Case where the first letter of the string is capitalized. In our tool above, we also call this Upper Camel Case. For example, userAccount is (lower) Camel Case and UserAccount is Pascal Case.

The main difference between camel case and Pascal Case is the coding standards you are supposed to use. Depending on who you work for, certain companies or coding practices may require you to use a one or the other.

What is Snake Case?

Snake case is the practice of writing compound words or phrases that are separated by an underscore instead of by spaces. It is often used by programmers to write variable names and sometimes for filenames. It is also very commonly used in Wikipedia URLs to separate words.

Basic Snake Case Capitalization Rules

  • All letters are lowercase.
  • All spaces between words are filled with underscores.
  • Remove all punctuation.

Snake Case Examples

  • “This is a sample sentence” turns into “this_is_a_sample_sentece”
  • “I love using snake case when I’m writing code”  turns into “i_love_using_snake_case_when_im_writing_code”

History of CamelCase

You might have already encountered several words such as, “FedEx,” and, “iPhone.” If you observe, some of the letters are capitalized in the middle of the word itself. These words are seemingly out of the conventional way of writing, but they are accepted as any grammar standard would be. There is actually a name for these words – Camel Case. The history of camel case has spanned ages, although it is most common now.

For those who may have no idea what a camel case is, there is no need to worry. On this article, we are going to identify what it is and how it is written. Moreover, we are also going to describe the history of camel case.

CamelCase Defined

Camel Case (stylized as CamelCase), is a convention of writing phrases or compound words in such a way that they form a single word. The first letter of each of the words is capitalized so that each of the words that would make up the constructed term could be read easily.

CamelCase is also known as camel caps, bi-capitalization, and medial capitals, the term itself was derived from the fact that the formed words with capitals seemingly resemble that of the humps of the camel. Say for instance, “PowerPoint.” The two capitalized letters look like the humps of the said animal.

There are two types of CamelCase. We have the Upper Camel Case (stylized as UpperCamelCase), in which the first letter of the newly formed word is in the upper case. Several examples of this include the words, “WordPerfect,” “WikiWord,” and the term, “CamelCase,” itself. The Lower Camel Case (stylized as lowerCamelCase) is noted for having its first letter in lower case. Examples of this include the following, “iPhone,” “iMac,” and “iPod.”

The History of Camel Case

As mentioned earlier, CamelCase has been used for quite a while. However, it only rose to prominence lately because of its usage in computer hard wares, soft wares, and product brands. This convention has gone through a lot since time immemorial. We will try to look into it.

Use in Chemistry

CamelCase was primarily used in chemistry as a way to notate chemical compounds and formulas. In 1813, Berzelius, a Swedish chemist, suggested that the chemical elements should be represented consisting of one or two letters with the first one capitalized. The term used for this convention was medical capitals.

Because of Berzelius’ suggestion, we do not write the symbol of Sodium Chloride (commonly known as salt) as Na Cl or NA CL. Instead, we write the formula as NaCl. While the letters are written without spaces, we can still read it without any confusion. In the scientific world, this system of writing is still in use up to this day. It is used in amino acid sequences of proteins and in naming unknown elements.

Use in Trademarks

In the early twentieth century, medical capitals used in Chemistry has been adopted in product trademarks and corporate names. However, the use is not yet prevalent. Some examples of these products include DryIce Corporation, CinemaScope, a widescreen movie format, MisterRogers, and VistaVision, among others.

Use in Computer Programming

Around the 1970s and 1980s, the use of medical capitals was also adopted as an alternative naming convention for identifiers in various programming languages. For instance, on the General Purpose Macro Processor (GPM) by Christopher Strachey, a program includes identifiers using medical capitals. These include “WriteSymbol,” and “NextCh.”

Mainstream Prevalence and Usage

The use of CamelCase spread throughout the computing world, albeit its uncertain origins. The practice became prevalent in the 1980s and 1990s. This was when the personal computer became a household name.

In time, this convention has been used in many business names. By 1990s, CamelCase has already become a common practice. Many of these examples are still active up until now. These include PolyGram (a former major music label), UnitedHealthCare (1977), MasterCard (1979), EchoStar (1980) BellSouth (1984), PageMaker (1985), HyperCard (1987), and HarperCollins (1990).

By the late 1990s, the lower camel case became a popular trend in many brands. The lowercase for “i” which may stand for internet, information, or intelligent, and “e” which stands for electronic, became prefixes to various words. Examples of these words include eBay, iMac, eBox, and iPod.

Coining of CamelCase

The term CamelCase only came into existence in the 1990s. Before that, the term medical capitals was commonly used. In April 1990, the term “InterCaps” was used by Avi Rappoport to describe the manner of capitalization. In 1991, Eric S. Raymond made mention of BiCapitalization to identify it.

It was not until 1995, however, that its current name was used. In a post by Newton Love, he mentioned that the humpiness of the style made him call it HumpyCase at first, before settling with CamelCase.

Current Usage

At present, CamelCase is used in various ways. For instance, wiki engines use this convention as their default settings. This is why we could see terms such as, “WikiWikiWeb,” “TiddlyWiki,” and “PmWiki.”

Using CamelCase in social networking and microblogging could reduce the number of spaces while allowing more content to fit in.

Many of the current programming identifiers also use CamelCase to make things easier. These would include, “sqlServer,” “oldHtmlFile,” and “parseDbmXml.” These identifiers are used in programming languages such as VisualBasic, C, and Java.

Abbreviations and acronyms such as academic qualifications also use CamelCase. For instance, we have BSc and PhD.

Snake Case Defined

Snake Case (stylized as snake_case) is also another word convention similar to CamelCase. This involves writing phrases or compound words in which the words are separated using an underscore symbol (_) instead of a space. The first letter of the words is typically written in lowercase. This convention is usually used in computer codes, function names, and filenames.

Examples of snake case include the following: “hello_world,” “first_document,” and “foo_bar.”

Various programming languages make use of snake case. Python uses snake case for variable names, function names, and package names, among others. C++ uses it for the standard library. Perl, on the other hand, uses it for subroutines and lexical variables. PHP uses snake case for functions.