ListFerret mascot

Home › Guides › camelCase vs PascalCase vs Title Case Explained

camelCase, snake_case and Title Case: Text Case Styles Explained

“Case” is how a piece of text is capitalised and how its words are joined. In everyday writing it decides how a headline looks. In programming it is a convention that makes names consistent and readable. This guide explains what camelCase, PascalCase, snake_case, kebab-case, Title Case and the rest actually mean, which style different languages and style guides expect, and the edge cases (acronyms, accents and other alphabets) that catch out converters.

One phrase, every style

Here is the same three-word phrase, “user account ID”, converted into each style by the Case Converter:

The Case Converter turning the text user account ID into camelCase, giving userAccountId, with all the available style buttons shown
One input, fourteen styles. The text is an invented example.
StyleResultTypical use
UPPER CASEUSER ACCOUNT IDShort labels, acronyms
lower caseuser account idNormalising data before comparing it
Sentence caseUser account IDHeadings and interface text in many modern style guides
Title CaseUser Account IDHeadlines and titles
camelCaseuserAccountIdVariables and functions in JavaScript, Java, Swift
PascalCaseUserAccountIdClass, type and component names
snake_caseuser_account_idPython, Ruby, Rust, database columns
CONSTANT_CASEUSER_ACCOUNT_IDConstants and environment variables
kebab-caseuser-account-idURLs, CSS class names, file names
Train-CaseUser-Account-IdHTTP header names
dot.caseuser.account.idConfiguration keys

In the programming styles the acronym “ID” becomes Id. That is a real convention rather than an error, and it is covered in the acronyms section below.

Styles for writing

Title Case depends on the style guide

There is no single rule for which words to capitalise in a title. The major guides disagree on the details:

GuideApproach to headlines and titles
AP (Associated Press)Headlines use sentence-style capitalisation: only the first word and proper nouns
ChicagoHeadline style: capitalise major words; lower-case articles, coordinating conjunctions and prepositions regardless of length
APATitle case for titles and main headings, capitalising words of four letters or more, including prepositions and conjunctions; sentence case for titles in reference lists
MLACapitalise first and last words and principal words; lower-case articles, prepositions and coordinating conjunctions

If your title has to follow a specific guide, check the converter’s output against that guide’s rules. Automated Title Case follows a general rule and cannot know your publication’s preferences.

Styles for code and file names

Names in code cannot contain spaces, so words are joined in a consistent way. Conventions differ by language:

Language or placeVariables and functionsTypes and classesConstants
JavaScript / TypeScriptcamelCasePascalCaseUPPER_SNAKE_CASE
Python (PEP 8)snake_casePascalCaseUPPER_SNAKE_CASE
JavacamelCasePascalCaseUPPER_SNAKE_CASE
C#camelCase for locals, PascalCase for methods and propertiesPascalCasePascalCase
GoMixedCaps; a leading capital exports the nameMixedCapsMixedCaps
Rustsnake_casePascalCaseSCREAMING_SNAKE_CASE
Rubysnake_casePascalCaseUPPER_SNAKE_CASE
CSS and HTMLkebab-case for class names, ids and custom properties (--main-color)
SQLsnake_case is common for table and column names; keywords are often written in upper case
URLs and file nameslower-case kebab-case; Google’s guidance recommends hyphens to separate words in URLs
Environment variablesUPPER_SNAKE_CASE

These are conventions, not laws, and a project’s own style guide wins. JSON keys are a good example of variety: JavaScript-oriented APIs usually use camelCase, while Python and Ruby APIs often use snake_case.

Case styles in coding: which one should you use?

If you are choosing a naming style for code, you rarely get to pick freely. The usual rule is to follow the convention of the language and the project you are working in. In outline:

When the language gives no guidance, pick one style per kind of name and keep to it. A mixed codebase is harder to read and search than one with an imperfect but consistent convention. These naming conventions apply to names written in code; for headings and titles, see the Title Case and Sentence case rows in the table above.

Why consistency matters

Mixed styles make code harder to read and cause real bugs, because many systems treat userId and userid as different names. For web addresses, hyphens are the safest choice: they are widely treated as word separators, while underscores tend to join words together. Choose one style per kind of name in a project and keep to it.

Converting between styles

Converting a long list of names by hand is slow and error-prone. Paste text into the Case Converter and click the style you want. For the programming styles it works out the words from spaces, punctuation and existing capital letters, so “User Account-ID”, userAccountId and user_account_id all become the same words in the new style. With one name per line and “convert each line separately” ticked, each line is converted on its own.

Edge cases that trip up converters

Frequently asked questions

What is camelCase?

camelCase joins words with no separator, writing the first word in lower case and capitalising the first letter of each following word, as in userAccountId. It is the usual style for variables and functions in JavaScript and Java.

What is the difference between camelCase and PascalCase?

In PascalCase the first word is capitalised too (UserAccountId), whereas camelCase starts with a lower-case letter (userAccountId). PascalCase is common for class and component names.

When should I use snake_case or kebab-case?

snake_case is standard in Python, Ruby and Rust and is common for database columns. kebab-case is common for URLs, CSS class names and file names because hyphens are treated as word separators.

What is the difference between Title Case and Capitalize Each Word?

Capitalize Each Word makes every word start with a capital. Title Case leaves small words such as “a”, “of” and “the” in lower case unless they start or end the title, following headline conventions.

How do I convert text to camelCase or snake_case?

Paste it into the Case Converter and click the style. Words are detected from spaces, punctuation and existing capital letters, so you can paste a phrase or a list of existing names.

Try it now: use the free Case Converter - private, instant and runs in your browser. Open Case Converter →

More guides

Share this page: XFacebookLinkedInRedditEmail