Camel Case: camelCase vs PascalCase With Examples
November 11, 2026 · 9 min read
Camel Case Explained: camelCase vs PascalCase With Examples
Camel case is a way of writing a phrase with no spaces, where each word after the first starts with a capital letter, as in firstName or getElementById. When the first word is capitalized too (FirstName), the style is called Pascal case. Below you'll see which form each language uses, plus the acronym and number rules.
What Is Camel Case? Definition and Where the Name Comes From
The MDN glossary defines it as writing a phrase without spaces, capitalizing the first letter of each word except possibly the first. The capitals in the middle stick up like the humps on a camel's back, which is where the name comes from. You'll also see it called camel caps or medial capitals.
There are two forms, and the only difference is the very first letter:
plain phrase: shipping address
lowerCamelCase: shippingAddress
UpperCamelCase: ShippingAddress
Both forms drop the space and mark the second word with a capital S. The lowercase-first form is sometimes called dromedary case, and the capitalized form is better known as Pascal case.
What Is Lower Camel Case?
This form starts with a lowercase letter and capitalizes the first letter of every later word: firstName, totalAmount, isLoggedIn. It's the standard form for variables, functions and methods in Java, JavaScript, Kotlin and Swift. JSON keys in web APIs often use it too, since they map straight onto JavaScript object properties.
Here's one line of JavaScript where every name follows this style:
const totalAmount = calculateTotal(cartItems, taxRate);
The variable totalAmount, the function calculateTotal and both arguments are multi-word names with no underscores or spaces. Your eye finds the word breaks from the capitals alone, which is the whole point of the style.
That gives the style two practical advantages. It needs no separator character, so names stay short. It also works in languages where a hyphen means subtraction: in JavaScript, total-amount is parsed as total minus amount, while totalAmount is one name.
Upper Camel Case and Pascal Case: One Style, Two Names
Upper camel case capitalizes every word, including the first: ShoppingCart, HttpClient, ArrayBuffer. Pascal case is the same style under another name. Microsoft's .NET guidelines call it PascalCasing, and Python's PEP 8 calls it CapWords while noting it's also known as CamelCase and StudlyCaps.
That overlap is why people ask whether it's camelCase or CamelCase. Both spellings are in use. Microsoft's guidelines use camelCasing only for the lowercase-first form, while PEP 8 uses CamelCase for the capitalized one. In a code review or style guide, write "lowerCamelCase" or "PascalCase" and nobody has to guess.
A capital first letter usually signals a type: a class, interface, struct or component. In React it isn't optional. The React docs say component names must start with a capital letter, because a lowercase tag such as section is read as a plain HTML element.
Pascal Case vs Camel Case: Which Goes Where by Language
Each major language's style guide splits names between the two forms. The pattern is broadly the same: types get Pascal case, while values and functions get camelCase. C# is the notable exception, because .NET puts methods and properties in Pascal case too.
| Language | Pascal case (upper camel) | camelCase (lower camel) | Source |
|---|---|---|---|
| Java | Classes and interfaces | Methods, non-constant fields, parameters, local variables | Google Java Style Guide |
| C# and .NET | Namespaces, types, methods, properties, events, public fields | Parameters | .NET Framework Design Guidelines |
| JavaScript and TypeScript | Classes and React components | Variables, functions, methods, properties | MDN and React docs (convention) |
| Python | Classes, exceptions, type variables | Rarely used | PEP 8 |
| Go | Exported names | Unexported names | Go language spec |
| Swift | Types and protocols | Everything else | Swift API Design Guidelines |
| Kotlin | Classes and objects | Functions, properties, local variables | Kotlin coding conventions |
Two rows need a note. In Go, the first letter's case is part of the language itself. The Go spec says a package-level name, field or method is exported, meaning other packages can use it, when its first character is an uppercase letter. So ParseConfig is public and parseConfig is private, and changing the case changes what compiles. Go package and folder names stay lowercase with no mixedCaps, as our Go folder structure guide explains.
Python is the odd one out. PEP 8 keeps CapWords for classes but doesn't recommend camelCase for functions or variables.
Here's a rule of thumb for the camel case vs Pascal case question. Use a capital first letter for things you define as types, and lowercase for things you call or assign. It holds in Java, JavaScript, Swift and Kotlin. It bends in C#, where methods are capitalized too, and in Go, where the capital means public.
How Do You Write a camelCase Name? A Step-by-Step Method
The Google Java Style Guide has the most precise recipe we've seen. It works in any language and settles the awkward cases where a phrase has punctuation or capitals already. Start from the plain English phrase:
- Convert it to plain ASCII and remove apostrophes, so "user's" becomes "users".
- Split it into words on spaces and any leftover punctuation, such as hyphens or brackets.
- Lowercase every word, acronyms included.
- Capitalize the first letter of each word except the first. For Pascal case, capitalize the first word as well.
- Join the words with nothing between them.
Here's the recipe applied to a few real phrases, camelCase first and PascalCase second:
"user's first name" -> usersFirstName / UsersFirstName
"read-only mode" -> readOnlyMode / ReadOnlyMode
"max file size (MB)" -> maxFileSizeMb / MaxFileSizeMb
"2 factor auth" -> twoFactorAuth / TwoFactorAuth
The last phrase needed one extra decision. JavaScript identifiers can contain digits but can't start with one, according to MDN, and most languages share that rule. Spell out a leading number, or reword the name so the digit lands later. If you need to convert labels in code, our JavaScript string case guide includes a camelCase helper.
Camel Case With Acronyms and Numbers: HTTPServer or HttpServer?
Acronyms are where the official guides disagree. Should "HTTP server" become HTTPServer or HttpServer? Each answer has a respected backer, so the right choice depends on your language:
- Treat acronyms as words. Google's Java guide lowercases everything first, so "XML HTTP request" becomes
XmlHttpRequestand "new customer ID" becomesnewCustomerId. - Split by acronym length. The .NET capitalization conventions give
HtmlTagfor longer acronyms but keep two-letter ones fully capitalized, as inIOStream. At the start of a camelCase name, both letters drop:ioStream. - Keep each acronym in one case. Go's code review comments ask for
ServeHTTP, notServeHttp, andappID, notappId. Swift's API guidelines agree, with examples likeutf8BytesandisRepresentableAsASCII. - Capitalize the whole acronym. PEP 8 says
HTTPServerErroris better thanHttpServerErrorfor Python class names.
We prefer treating acronyms as words (HttpServer, parseJson) unless your language's guide says otherwise. Two acronyms in a row show why: XMLHTTPRequest hides where one ends, while XmlHttpRequest keeps every boundary visible. MDN even points out that the browser's own XMLHttpRequest mixes both approaches.
Numbers are the style's real limitation, because digits have no uppercase form. Google's guide writes "Turn on 2SV" as turnOn2sv. When two numbers sit side by side, as in version 33.4.6, the style can't separate them, so the guide falls back to an underscore: guava33_4_6.
Camel Case Examples Outside Code: Brands and Hashtags
You've probably seen this style in product names before you saw it in code. Familiar brand spellings include iPhone and eBay, which start lowercase, and YouTube and PowerPoint, which start with a capital. These are trademarks rather than rules, so they don't follow any one guide.
Hashtags are the most useful case outside programming. Writing #MarkdownTips instead of #markdowntips makes the words easier to spot at a glance. Many social media accessibility guides recommend capitalizing each word in a hashtag, because screen readers can then pick out the separate words. An all-lowercase tag may be read aloud as one long word instead.
Writing camelCase Names in Markdown Documentation
When you document code in Markdown, most of the names you mention are camelCase or PascalCase. Wrap each one in inline code. Readers can then tell an identifier from an ordinary word and copy it exactly.
Call `getElementById()` with the element's `id`, then read its `textContent`.
That renders as a normal sentence with three names in a monospaced font. The backticks also stop Markdown from reading underscores or asterisks inside a name as formatting. Our Markdown code block guide covers inline code and fenced blocks in more depth.
Front matter keys follow whatever your site generator expects. Hugo, for example, uses camelCase keys such as publishDate and linkTitle, and the front matter guide shows the syntax. Pick one naming convention per doc set and write it down in your Markdown style guide. Whether to use underscores instead of capitals is a separate debate this guide doesn't cover. Our snake case guide compares the two styles side by side.
Camel case comes down to one choice: does the first letter stay lowercase or not? Follow your language's style guide for that, and for acronyms, and keep the choice consistent across your codebase and docs. To switch a phrase into camelCase, PascalCase or nine other styles, paste it into our case converter, which runs in your browser. Then document the names in inline code in the free Markdown editor.