Naming things in code looks simple until a project grows. Then suddenly, inconsistent naming starts slowing everyone down. Kebab Case, CamelCase and PascalCase are often treated as style preferences, but in practice, they shape how developers read and reason about code usage in the program. camelCase is used for variables and functions, PascalCase for classes and components, and kebab-case for URLs and CSS.
Understanding when to use each one is less about rules and more about clarity that all can understand.
Quick Cheat Sheet
| Style | Looks like | Use it for |
|---|---|---|
| camelCase | userName | Variables and functions in JavaScript and Java |
| PascalCase | UserAccount | Classes, React components, types (all languages) |
| snake_case | user_name | Variables and functions in Python |
| UPPER_SNAKE_CASE | MAX_RETRIES | Constants in Python, Java and JavaScript |
| kebab-case | user-profile | CSS classes, URLs, file names |
Save this table and you’ll get naming right in most projects. The rest of the post explains why, with examples in JavaScript, Python, Java and CSS.
Syntax vs Semantics in Naming
Syntax refers to how code is written.
Semantics refers to what the code communicates.
In naming conventions, camelCase and PascalCase are syntactic differences. Both are valid and won’t affect how the program runs.
Semantically, they signal intent:
- camelCase usually represents variables or functions
- PascalCase usually represents classes or components
This visual distinction helps developers understand code faster without reading implementation details.
Also Read | Common WordPress Problems
What Is camelCase?
camelCase starts with a lowercase letter, and each new word begins with an uppercase letter.
Examples:
userName totalPrice isAuthenticated
camelCase is commonly used for:
- Variables
- Functions
- Methods
- Object properties
It reads naturally in expressions and works well when chaining logic. In most modern languages, camelCase is the default for anything that performs an action or stores a value.
What Is PascalCase?
PascalCase starts with an uppercase letter, and every new word is also capitalized.
Examples:
UserAccount PaymentService OrderController
PascalCase is typically used for:
- Class names
- Constructors
- React or UI components
- Types and interfaces (in typed languages)
PascalCase signals structure. When developers see it, they expect something that represents a concept, not an operation.
Camel Case vs Pascal Case: When to Use Each
| Use Case | Recommended Style |
|---|---|
| Variables | camelCase |
| Functions / Methods | camelCase |
| Classes | PascalCase |
| React Components | PascalCase |
| Types / Interfaces | PascalCase |
These conventions help code communicate intent visually. You can often tell what a piece of code represents without reading its body.
When to Use What
The short table above covers the two styles people search for most. This one is the fuller cheat sheet: pick the thing you are naming, then use the convention next to it. SCREAMING_SNAKE_CASE is the same style as UPPER_SNAKE_CASE.
| What you’re naming | Convention | Example |
|---|---|---|
| Variables | camelCase (snake_case in Python, Go and Rust) | userName / user_name |
| Functions / methods | camelCase (snake_case in Python and Rust) | calculateTotal() / calculate_total() |
| Classes / types | PascalCase | UserAccount, PaymentService |
| Constants | SCREAMING_SNAKE_CASE (PascalCase for public constants in C#) | MAX_RETRIES, API_BASE_URL |
| Components (React) | PascalCase | UserProfileCard |
| Files | Follow the language (see examples below) | user-profile.tsx, order_service.py, OrderService.java |
| CSS classes | kebab-case | .user-profile-card |
| URLs / slugs | kebab-case | /camel-case-vs-pascal-case/ |
| DB columns | snake_case | user_name, created_at |
| JSON / API keys | camelCase or snake_case, but stay consistent | userName or user_name |
| Env vars | SCREAMING_SNAKE_CASE | DATABASE_URL, API_KEY |
If your linter or style guide already picks a style, follow that. Consistency in one codebase matters more than picking the “perfect” convention.
Language-Specific Expectations
JavaScript and TypeScript
- camelCase for variables, functions, hooks
- PascalCase for classes, components, and types
- UPPER_SNAKE_CASE for constants that never change
const maxItems = 10; // camelCase variable
const API_BASE_URL = "https://api.example.com"; // constant
function calculateTotal(items) { // camelCase function
return items.reduce((sum, item) => sum + item.price, 0);
}
class ShoppingCart { // PascalCase class
addItem(item) { /* ... */ }
}
function UserCard({ userName }) { // PascalCase React component
return <div className="user-card">{userName}</div>;
}
React needs PascalCase for components: a lowercase tag like <userCard /> is treated as a plain HTML element, not your component.
If you are getting started with components, see our guide to state and props in React. Frontend frameworks also ship their own file and component conventions; our overview of JavaScript frameworks vs libraries covers how React, Vue, Svelte and Angular differ.
Also Read | JavaScript Naming Conventions
Java
- camelCase for methods and variables
- PascalCase for classes and interfaces
- UPPER_SNAKE_CASE for constants (
static final) - all lowercase for package names, like
com.tekraze.orders
public class OrderService { // PascalCase class
private static final int MAX_ORDERS = 100; // UPPER_SNAKE_CASE constant
private int orderCount; // camelCase field
public double calculateTotal(Order order) { // camelCase method
return order.getPrice() * order.getQuantity();
}
}
Python
Python is the big exception. Its official style guide, PEP 8, uses snake_case for variables and functions instead of camelCase.
- snake_case for variables, functions and modules
- PascalCase for classes
- UPPER_SNAKE_CASE for constants
MAX_RETRIES = 3 # constant
def calculate_total(items): # snake_case function
return sum(item.price for item in items)
class ShoppingCart: # PascalCase class
def add_item(self, item): # snake_case method
self.items.append(item)
If you write calculateTotal in Python, it still runs, but linters like flake8 or Ruff (with naming rules on) will flag it, and it looks out of place to other Python developers.
C# / .NET
- PascalCase for public members and classes
- camelCase for private fields and method parameters
Each ecosystem has its own expectations. Following them makes your code easier for others to understand and maintain.
public class OrderService
{
public const int MaxRetries = 3; // PascalCase public constant
private int orderCount; // camelCase private field
public decimal CalculateTotal(Order order) // PascalCase public method
{
return order.Price * order.Quantity;
}
}
C# is the odd one out among these examples: public methods and public constants use PascalCase (CalculateTotal, MaxRetries), not camelCase or SCREAMING_SNAKE_CASE. Private fields and parameters stay camelCase.
Go
Go uses capitalization for visibility, not a separate “constant style.” A name that starts with an uppercase letter is exported (visible outside the package). A lowercase name stays private to the package.
- PascalCase for exported functions, types, fields and constants
- camelCase for unexported functions, fields and constants
package orders
const MaxRetries = 3 // exported constant
type OrderService struct { // exported type (PascalCase)
orderCount int // unexported field (camelCase)
}
func (s *OrderService) CalculateTotal(order Order) float64 { // exported method
return order.price * float64(order.quantity)
}
func calculateDiscount(price float64) float64 { // unexported helper
return price * 0.1
}
Rust
Rust is close to Python on names, with a compiler that will warn you if you drift.
- snake_case for functions, methods, modules and variables
- PascalCase for types, traits and enum variants
- SCREAMING_SNAKE_CASE for constants and statics
const MAX_RETRIES: u32 = 3; // SCREAMING_SNAKE_CASE
struct OrderService { // PascalCase type
order_count: u32, // snake_case field
}
impl OrderService {
fn calculate_total(&self, price: f64, quantity: u32) -> f64 { // snake_case method
price * f64::from(quantity)
}
}
fn calculate_discount(price: f64) -> f64 {
price * 0.1
}
Language-wise conventions at a glance
Use this as a quick map when you switch languages in the same week.
| Language | Variables / functions | Classes / types | Constants | Notes |
|---|---|---|---|---|
| JavaScript / TypeScript | camelCase | PascalCase | SCREAMING_SNAKE_CASE | React components are PascalCase |
| Python | snake_case | PascalCase (CapWords) | SCREAMING_SNAKE_CASE | Follow PEP 8 |
| Java | camelCase | PascalCase | SCREAMING_SNAKE_CASE | Package names are all lowercase |
| Go | camelCase if unexported, PascalCase if exported | PascalCase if exported | Same export rule as other names | The first letter controls visibility |
| Rust | snake_case | PascalCase | SCREAMING_SNAKE_CASE | rustc / rustfmt will flag mismatches |
| C# / .NET | camelCase for locals, fields and parameters; PascalCase for public methods | PascalCase | PascalCase for public constants | Follow the Microsoft naming guidelines |
| CSS / HTML | kebab-case (classes, IDs, custom properties) | — | kebab-case custom properties | --primary-color, .user-card |
Common Naming Mistakes
Using PascalCase for functions
function CalculateTotal() { } // Misleading
This looks like a class, not a function.
Using PascalCase for variables
let UserName = "John"; // Confusing
It visually suggests a type or constructor.
Mixing styles without meaning
Inconsistent naming doesn’t break code, but it breaks readability and slows down collaboration.
Also Read | Free Graphic Design Website for Graphic Designers
What Is kebab-case?
kebab-case uses all lowercase letters, with words separated by hyphens.
Examples:
user-profile total-price order-history-page
kebab-case is commonly used for:
- URLs and slugs
- File names
- CSS class names
- HTML attributes
Unlike camelCase and PascalCase, kebab-case is not used inside most programming languages for variables or functions, mainly because hyphens are interpreted as subtraction operators.
Why kebab-case Exists (And Where It Makes Sense)
kebab-case is optimized for readability outside code execution.
- URLs are easier to read and scan
- Search engines prefer hyphen-separated words
- CSS and HTML conventions rely on it heavily
For example, in HTML:
<div class="user-profile-card"></div>
Trying to use kebab-case inside JavaScript variables would break the syntax, but in markup and URLs, it’s the most natural choice.
CSS
CSS is where kebab-case lives. Class names, IDs and custom properties (CSS variables) are usually written in kebab-case.
:root {
--primary-color: #1e88e5; /* kebab-case custom property */
}
.user-profile-card { /* kebab-case class */
background-color: var(--primary-color);
}
Built-in CSS properties are kebab-case too, like background-color and font-size. When you read them from JavaScript, they switch to camelCase: element.style.backgroundColor.
Examples for Files, URLs, JSON, Databases and Env Vars
The styles above are not only for variables and classes. The same names show up in file names, slugs, API payloads and config, and each of those layers has a usual convention.
File names
user-profile.tsx # kebab-case, common for routes and CSS-adjacent files UserProfile.tsx # PascalCase, common for a React component file order_service.py # snake_case, Python module OrderService.java # PascalCase, must match the public class user_profile.go # snake_case, Go file order_service.rs # snake_case, Rust file
URLs and slugs
Search engines and humans both read hyphens more easily than jammed-together words, which is why kebab-case is the default for slugs and paths.
https://tekraze.com/right-way-to-code-syntax-camel-case-vs-pascal-case/ https://api.example.com/users/user-profile /order-history
JSON and API keys
JavaScript APIs usually use camelCase keys. Many Python, Ruby and PHP backends, and most SQL columns, use snake_case. Either works, as long as one API does not mix both.
{
"userName": "ada",
"totalPrice": 499,
"isAuthenticated": true
}
Database columns
SQL is case-insensitive in a lot of setups, so snake_case is the usual choice for table and column names.
users.user_name users.created_at orders.total_price orders.payment_status
Environment variables
Env vars are almost always SCREAMING_SNAKE_CASE, even in JavaScript and C# projects, because shells and deployment platforms treat them as constants.
DATABASE_URL=postgres://localhost:5432/app API_BASE_URL=https://api.example.com MAX_RETRIES=3
camelCase vs PascalCase vs kebab-case (Quick Comparison)
| Naming Style | Common Usage |
|---|---|
| camelCase | Variables, functions, methods (JS, Java) |
| snake_case | Variables, functions (Python) |
| PascalCase | Classes, components, types |
| kebab-case | URLs, CSS classes, file names |
Each naming style serves a different layer of the stack:
- Logic layer → camelCase
- Structure layer → PascalCase
- Presentation & routing layer → kebab-case
Common Mistake With kebab-case
Using kebab-case where the language doesn’t support it:
let user-name = "John"; // Invalid JavaScript
This is why understanding context matters more than preference when choosing naming conventions.
Also Read | Tailoring Web Design for Niche Markets
Why Naming Conventions Matter in Real Projects
In small scripts, naming style rarely matters. In large codebases, it matters a lot.
Consistent naming:
- Reduces cognitive load
- Makes code easier to scan
- Improves onboarding for new developers
- Supports tooling, linters, and IDEs
Good naming acts as silent documentation. Bad naming creates friction that compounds over time.
That same idea shows up when you practise algorithms: consistent names make examples easier to scan. Our data structures cheat sheet uses Java, Python and Rust examples throughout.
Final Recommendation
- Use camelCase when something acts
- Use PascalCase when something represents
- Use kebab-case when something needs to be read by humans or browsers
That simple distinction covers most real-world scenarios. In Python, swap camelCase for snake_case.
FAQ
What is the difference between camelCase and PascalCase?
Only the first letter. camelCase starts lowercase (userName), PascalCase starts uppercase (UserName). Use camelCase for things that act or hold values, and PascalCase for classes and components.
Does Python use camelCase?
Not by convention. PEP 8 recommends snake_case for functions and variables and PascalCase (it calls it CapWords) for classes.
Why can’t I use kebab-case for variables?
Because most languages read the hyphen as a minus sign. user-name means “user minus name”.
Is PascalCase the same as UpperCamelCase?
Yes. Some style guides call PascalCase “UpperCamelCase” and camelCase “lowerCamelCase”.
Which naming style is better for JavaScript?
Neither is better in the abstract. In JavaScript and TypeScript, camelCase is the convention for variables, functions and object properties, and PascalCase is the convention for classes, components and types. Follow the language and your linter (ESLint or typescript-eslint) instead of inventing a third style.
Should JSON keys use camelCase or snake_case?
Use camelCase if the API is mainly consumed by JavaScript or TypeScript. Use snake_case if the API follows a Python, Ruby or Rails backend, or if the keys map one-to-one onto database columns. The important part is not which one you pick: it is that every endpoint in the same API uses the same style. Convert at the edges if your backend and frontend disagree.
Conclusion
camelCase and PascalCase are not competing styles. They serve different purposes. When used consistently, they help code communicate meaning without extra comments or explanations.
Follow the conventions of the language and framework you’re using. Consistency will always matter more than personal preference.





