One Click Answers

camelCase, snake_case and kebab-case explained

camelCase, snake_case and kebab-case are three set ways of joining words without spaces. Code, file names and web addresses cannot contain spaces, so words are joined in a few set styles. Each has a name, and each is used in different places by convention.

One phrase, every style

The phrase user profile page in each style
StyleResult
camelCaseuserProfilePage
PascalCaseUserProfilePage
snake_caseuser_profile_page
kebab-caseuser-profile-page
CONSTANT_CASEUSER_PROFILE_PAGE

Where each is usually used

  • camelCase: variable and function names in JavaScript and many other languages.
  • PascalCase: class and component names.
  • snake_case: variables in Python and Ruby, and many database column names.
  • kebab-case: web addresses, file names and CSS class names. Hyphens are easy to read and are treated as word separators in a web address.
  • CONSTANT_CASE: fixed values that should never change.

These are conventions, not laws. The right choice is whatever the project or language you are working in already uses.

Why kebab-case suits web addresses

A hyphen reads as a word break, so a page address like user-profile-page is easy for both people and search engines to read. Underscores and joined-together words are harder to separate.

Converting a list of names

If you are renaming many items, paste them in and convert in one step instead of editing each by hand. Check the result for acronyms, which a converter may split or join in ways you did not intend.

Keep one style per project

The real cost of naming styles is inconsistency. A project where some files are in kebab-case, some in snake_case and some in camelCase is hard to search and easy to get wrong. Choose one convention for each kind of thing, write it down in a sentence, and convert anything that arrives in another style as soon as it comes in.

Case Converter: Convert any phrase to camelCase, PascalCase, snake_case, kebab-case or CONSTANT_CASE.

Published by OneClickAnswers.

You might also wonder...

Try it yourself

  • Case ConverterChange text case instantly: upper, lower, title and more.

← All articles

Got another question?

Free, no account. Answers show how they were worked out.