PascalCase Explained: When and How to Use It in Code
PascalCase is the naming convention where every word in an identifier begins with a capital letter — including the first one — and there are no spaces or separators between the words. It is named after the Pascal programming language, where it was the recommended style for procedures and types. Today, PascalCase is the conventional style for class names, type names, and component names across nearly every modern object-oriented language.
What PascalCase Looks Like
The rules are simple: take the words that make up the identifier, capitalize the first letter of each, and concatenate them with nothing in between. Acronyms are typically treated as whole words and capitalized only on the first letter in modern style guides (e.g., XmlHttpRequest not XMLHTTPRequest), although older code often capitalizes the entire acronym.
PascalCase examples:
UserProfile
HttpRequestHandler
InvoiceLineItem
ShoppingCartService
NotFoundException
PascalCase vs camelCase
The two styles are visually almost identical — only the first character differs. camelCase keeps the first word lowercase (userProfile); PascalCase capitalizes it (UserProfile). This tiny difference is used to encode semantic information in many languages: PascalCase signals a type or class, while camelCase signals a value, variable, or function.
| Style | Example | Typical use |
|---|---|---|
| PascalCase | UserProfile | Classes, types, components |
| camelCase | userProfile | Variables, functions, methods |
| SCREAMING_SNAKE | USER_PROFILE | Constants |
| snake_case | user_profile | Python/Ruby vars, DB columns |
For a deeper dive, see our comparison of camelCase vs PascalCase.
Where PascalCase Is Required or Conventional
C# and .NET
Microsoft's official C# naming guidelines mandate PascalCase for namespaces, classes, structs, enums, interfaces (prefixed with I: IDisposable), public methods, public properties, and public fields. camelCase is used only for private fields (often with a leading underscore) and local variables.
Java
Java uses PascalCase for class and interface names: ArrayList, HttpServlet, RuntimeException. Methods and variables use camelCase. Constants use SCREAMING_SNAKE_CASE.
TypeScript and React
TypeScript uses PascalCase for types, interfaces, enums, and class names. React components — whether function or class — must use PascalCase because JSX uses the leading capital letter to distinguish a component from a regular HTML tag. <Button /> renders a React component; <button /> renders an HTML element.
React component naming:
✅ function UserCard() { return <div>...</div>; }
✅ <UserCard name="Alice" />
❌ function userCard() — React will treat <userCard /> as an unknown HTML tag.
Go
Go uses capitalization to control visibility. An identifier that starts with a capital letter (PascalCase) is exported from its package; one that starts lowercase (camelCase) is package-private. This means PascalCase is not just a style choice in Go — it changes the meaning of your code.
Common PascalCase Mistakes
Mistake 1: Over-Capitalizing Acronyms
Old code often wrote parseHTMLString or HTTPSConnection. Most modern style guides (Microsoft, Google, Airbnb) now recommend treating multi-letter acronyms like ordinary words: parseHtmlString, HttpsConnection. Two-letter acronyms like ID and IO are usually kept fully uppercase: UserID, IOStream.
Mistake 2: Using PascalCase for Variables
A variable named UserName in C# or Java will confuse other developers because it looks like a class. Use camelCase for variables and reserve PascalCase for types and constructors.
Mistake 3: Lowercasing React Components
This is the most common error for new React developers. If you name a component menuItem, React will not render it as a component — it will look for an HTML element called menuitem and warn that it is unknown.
How to Convert to PascalCase Programmatically
The basic algorithm is: split the input on whitespace, hyphens, and underscores; lowercase each token; capitalize the first letter of each token; concatenate. For tricky inputs like iPhone or eBay, you may need a dictionary of brand names to preserve their original casing. You can use our PascalCase converter for one-off conversions, or implement the function in roughly five lines of JavaScript, Python, or any other language.
Frequently Asked Questions
Is PascalCase the same as UpperCamelCase?
Yes. "UpperCamelCase" is a synonym for PascalCase. Some style guides (notably Microsoft's older docs) call camelCase "lowerCamelCase" and PascalCase "UpperCamelCase" to emphasize they are variants of the same idea.
Why is PascalCase used for class names?
Convention. Most modern languages inherited the style from Smalltalk, where classes were always named with an initial capital. Visual contrast between class names and instance variables makes code easier to read.
Should I use PascalCase or kebab-case for file names?
It depends on the ecosystem. React projects commonly use PascalCase for component files (UserCard.tsx). Most other JavaScript projects prefer kebab-case (user-card.js). Python uses snake_case for module files.