Front-end8 min read
camelCase, PascalCase, kebab-case, snake_case: when to use
When to use camelCase, PascalCase, kebab-case, snake_case and UPPER_CASE in TypeScript, Python, Go, C#, CSS, URLs, databases and Git, with a tested lint rule.

Every project has that discussion: is the file UserProfile.tsx or user-profile.tsx? Is the column createdAt or created_at? Does the constant go in uppercase? It looks like a detail, but inconsistent names are expensive: you get imports wrong, search for the wrong thing in the editor and lose time in code review arguing about taste.
The good news is that there's almost never any taste to argue about. Each language, format and tool already has an official or dominant convention. This post gathers the main ones in one place and explains the reason behind each, which is what helps you remember.
An honest note: each language's rules come from the official guides (linked at the end), and the lint config at the end was tested: a correct file passes and a wrong one flags all five errors.
TL;DR#
- camelCase (
firstName): variables, functions and properties in JavaScript, TypeScript, Java and JSON. - PascalCase (
UserProfile): classes, types, interfaces and components, in almost every language. - snake_case (
first_name): Python, Rust, Ruby and table and column names in databases. - kebab-case (
user-profile): CSS, URLs, file names on the web, npm packages and branches. - UPPER_CASE (
MAX_RETRIES): constants and environment variables. - The rule that beats all the others: follow the convention of the language and the project, and let a lint tool enforce it.
The name of each style#
| Style | Example | Other names |
|---|---|---|
| camelCase | orderTotal | lowerCamelCase |
| PascalCase | OrderTotal | UpperCamelCase, CapWords (in Python) |
| snake_case | order_total | |
| kebab-case | order-total | dash-case, spinal-case |
| UPPER_CASE | ORDER_TOTAL | SCREAMING_SNAKE_CASE, CONSTANT_CASE |
| flatcase | ordertotal | used in Go and Java packages |
The name kebab comes from the skewer: the words are stuck on the hyphen.
By language#
JavaScript and TypeScript#
export const MAX_RETRIES = 3;
export enum OrderStatus { Pending, Paid }
export interface UserProfile { firstName: string; isAdmin: boolean }
export class OrderService {
private readonly baseUrl = '/api';
getOrders(customerId: string) { return `${this.baseUrl}/customers/${customerId}`; }
}
export function OrderCard() { return null; }
export function formatPrice(value: number) {
const isFree = value === 0;
const headers = { 'Content-Type': 'application/json' };
return isFree ? 'Free' : `${value} ${headers['Content-Type']}`;
}- camelCase for variables, functions, parameters, methods and properties.
- PascalCase for classes, interfaces, types, enums and React components (React requires a component to start with an uppercase letter, to tell it apart from an HTML tag).
- UPPER_CASE for module constants that represent a fixed value, like a limit or a setting. A
constinside a function stays in camelCase:constsays the variable doesn't change, not that it's a "constant" in the configuration sense.
Google's TypeScript style guide follows exactly this split.
Python#
MAX_RETRIES = 3
class OrderService:
def get_orders(self, customer_id: str) -> list[dict]:
is_cached = customer_id in self._cache
...PEP 8, Python's official guide, defines: snake_case for functions, variables and methods, CapWords (PascalCase) for classes, UPPER_CASE for constants, and short, lowercase module names. A leading _ (_cache) signals internal use.
Go#
Go has a twist: uppercase changes behavior. A name that starts with an uppercase letter (GetOrders) is exported, visible outside the package. With a lowercase letter (getOrders), it stays private to the package. That's why Go uses MixedCaps and not snake_case, and package names are short and lowercase, with no separator.
C# and .NET#
Microsoft documents: PascalCase for classes, methods and public properties, camelCase for parameters and local variables, _camelCase for private fields, and interfaces starting with I (IOrderService).
Java#
Classes in PascalCase, methods and variables in camelCase, constants in UPPER_CASE and packages all lowercase (com.example.orders).
Rust#
The language's official guidelines ask for snake_case for functions, variables and modules, UpperCamelCase for types and traits and SCREAMING_SNAKE_CASE for constants. The compiler warns when a name strays from that.
Outside the code#
CSS and HTML#
.order-card { display: grid; }
.order-card__title { font-weight: 600; }
.order-card--selected { outline: 2px solid currentColor; }
:root { --color-accent: #ff385c; }- kebab-case is CSS's own standard (
background-color,font-weight), and classes follow the same style. - BEM is a popular convention on top of that: block (
order-card), element (__title) and modifier (--selected). - CSS variables are in kebab-case too, with
--in front. - A custom element in HTML needs a hyphen in its name, by the spec's rules:
<order-card>is valid,<ordercard>isn't. That's how the browser tells your tag apart from a native one.
URLs#
/articles/smart-and-dumb-components, not /articles/smart_and_dumb_components. Google's documentation for search recommends hyphens to separate words in URLs. Also use only lowercase: URLs are case sensitive, and /About and /about become two pages.
File names#
Here the ecosystem splits, and what counts is the framework's convention:
- Angular: kebab-case, with the official guide asking for the file name to match the class (
UserProfileinuser-profile.ts). - React: it's common for the component file to follow the component's name (
UserProfile.tsx), and the rest in kebab-case or camelCase. There's no official rule, so pick one and document it. - Python: snake_case, because the file name becomes the module name in the
import.
One thing that catches a lot of people: macOS and Windows, by default, don't distinguish uppercase from lowercase in file names, and Linux does. If you rename button.tsx to Button.tsx on a Mac, Git may not notice the change, your import works on your machine and breaks in CI, which runs on Linux. To change only the case, use git mv button.tsx Button.tsx.
Databases#
CREATE TABLE customer_orders (
id BIGSERIAL PRIMARY KEY,
customer_id BIGINT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);Lowercase snake_case is the safest standard. In PostgreSQL, unquoted names are folded to lowercase: if you create the column createdAt without quotes, it becomes createdat. To keep the uppercase, you have to write "createdAt" with quotes in every query, forever.
APIs and JSON#
There's no consensus. Google's JSON style guide uses camelCase for properties, which is natural for anyone consuming it in JavaScript. Many large public APIs use snake_case. What matters is picking one and keeping it across the whole API. If the database is snake_case and the front end is camelCase, do the conversion in a single place, in the layer that builds the response, not scattered through the code.
Environment variables#
DATABASE_URL, API_KEY, NODE_ENV. UPPER_CASE with underscores is the convention across all Unix systems, and the POSIX specification describes the names of the variables used by its utilities that way: uppercase letters, digits and underscores.
Git#
- Branches: kebab-case with a prefix for the type of work:
feat/order-filter,fix/login-redirect. - Commit messages: the Conventional Commits spec uses
type(scope): description, likefix(orders): keep selection after reload.
Beyond case: names that explain themselves#
The casing convention is the easy part. What helps the reader most is a name that says what the thing is:
- Booleans as questions:
isOpen,hasItems,canEdit,shouldRetry.openalone could be a verb, a state or a function. - Functions with verbs:
getOrders,formatPrice,saveDraft. Components and classes with nouns:OrderCard,PriceFormatter. - Lists in the plural:
ordersis a list,orderis one item.orderListis redundant. - No obscure abbreviations:
customerId, notcId. The exceptions are the ones everyone knows:id,url,html. - Acronyms as words: Google's guide recommends treating an acronym like an ordinary word,
loadHttpUrland notloadHTTPURL, because it stays readable and works with any convention. - Events and handlers named for what they do:
saveUserData()says more thanhandleClick(). The Angular style guide recommends this explicitly.
Let the tool enforce it#
A convention that depends on memory and code review gets lost. In TypeScript, typescript-eslint's naming-convention rule enforces all of this in the editor and in CI:
import tseslint from 'typescript-eslint';
export default tseslint.config({
files: ['**/*.ts', '**/*.tsx'],
languageOptions: { parser: tseslint.parser, parserOptions: { projectService: true } },
plugins: { '@typescript-eslint': tseslint.plugin },
rules: {
'@typescript-eslint/naming-convention': [
'error',
// Default: camelCase for variables, functions, parameters and members.
{ selector: 'default', format: ['camelCase'] },
// React components are functions written in PascalCase.
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
// Module-level constants may be UPPER_CASE.
{ selector: 'variable', modifiers: ['const', 'global'], format: ['camelCase', 'UPPER_CASE', 'PascalCase'] },
// Types, interfaces, classes and enums in PascalCase.
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'enumMember', format: ['PascalCase'] },
// Booleans read like a question: isOpen, hasItems, canEdit.
{ selector: 'variable', types: ['boolean'], format: ['PascalCase'], prefix: ['is', 'has', 'should', 'can'] },
// Object keys that come from outside (HTTP headers, APIs) are left alone.
{ selector: 'objectLiteralProperty', format: null },
],
},
});Testing it with a wrong file:
export interface user_profile { first_name: string }
export function Format_price(Value: number) {
const free = Value === 0;
return free;
}ESLint flagged all five problems: the user_profile interface and the first_name property off the pattern, the Format_price function, the Value parameter and the free boolean without a question prefix. The file at the start of the post passed with no errors.
A version detail: typescript-eslint 8.73, the current version in November 2026, still requires TypeScript below 6.1. In a project that has already moved to TypeScript 7, check compatibility before installing.
For Python, Ruff has the PEP 8 naming rules (the N group). In Go and Rust, the language's own tooling already complains.
Checklist#
- Variables and functions in the language's style (camelCase in JS/TS, snake_case in Python).
- Classes, types and components in PascalCase.
- Configuration constants and environment variables in UPPER_CASE.
- CSS, URLs, packages and branches in kebab-case, lowercase only.
- Tables and columns in snake_case, without quotes.
- Files following the framework's convention, and case changes done with
git mv. - Booleans as questions, functions with verbs, lists in the plural.
- A lint rule enforcing it, instead of code review.
References#
- Google TypeScript style guide
- PEP 8: naming conventions in Python
- Effective Go: names
- C# identifier naming rules
- Rust API Guidelines: naming
- Angular style guide
- URL structure, Google Search Central
- Google JSON style guide
- Identifiers in PostgreSQL
- Conventional Commits
- typescript-eslint naming-convention
Comments
Sign in with your GitHub account to comment.
Read next

Front-end10 min read
Signals in Angular 22: signal, computed, effect and beyond

Front-end12 min read
Smart and dumb components in Angular and React, in 2026

Front-end10 min read
Storybook: how to start and how far it's worth going