“There are only two hard things in computer science: cache invalidation and naming things.” The naming part isn’t just about what you call something — it’s also about the style you write it in. Different languages and ecosystems favour different conventions, and mixing them up makes code look sloppy. Here’s a practical guide.
The same string in every convention.
the lord of the rings: return of the kingthrough our case converter:camelCase theLordOfTheRings:ReturnOfTheKing PascalCase TheLordOfTheRings:ReturnOfTheKing snake_case the_lord_of_the_rings:_return_of_the_king kebab-case the-lord-of-the-rings:-return-of-the-kingNotice what the colon did: it survives in camel and Pascal but disappears in snake and kebab, because those two treat any non-word character as a separator. That is the practical rule — snake and kebab are safe for filenames and URLs precisely because they throw punctuation away, while camel and Pascal keep whatever you gave them.
The main styles
- camelCase — first word lowercase, each subsequent word capitalized:
myVariableName. The default for variables and functions in JavaScript, Java, and many others. - PascalCase (a.k.a. UpperCamelCase) — every word capitalized:
MyVariableName. Used for classes, types and React components. - snake_case — all lowercase, words joined by underscores:
my_variable_name. The Python and Ruby standard for variables and functions; also common in database column names. - kebab-case — all lowercase, words joined by hyphens:
my-variable-name. Used for URLs, CSS classes, and file names. (Not valid for identifiers in most languages because the hyphen reads as a minus sign.) - CONSTANT_CASE (SCREAMING_SNAKE_CASE) — all uppercase with underscores:
MAX_RETRY_COUNT. Conventionally used for constants and environment variables.
Which language uses what?
Conventions are strong signals of “fitting in” with a codebase:
- JavaScript / TypeScript — camelCase for variables and functions, PascalCase for classes and types, CONSTANT_CASE for true constants.
- Python — snake_case for functions and variables, PascalCase for classes, CONSTANT_CASE for module constants (PEP 8).
- Go — PascalCase for exported names, camelCase for unexported ones.
- CSS — kebab-case for class names (
.main-nav) and custom properties (--brand-color). - URLs & files — kebab-case is preferred (
/blog/my-post) because it’s readable and URL-safe.
Title Case vs. Sentence case
Two more styles apply to prose rather than code:
- Title Case capitalizes the first letter of each word — used for headings (“A Naming Conventions Guide”).
- Sentence case capitalizes only the first letter of the whole line — increasingly popular for UI labels and headings because it reads more naturally.
Converting between styles
You’ll often need to convert a name from one style to another — for example, turning a database column created_at (snake_case) into a JSON field createdAt (camelCase) for an API. Doing this by hand is tedious and error-prone.
Our case converter does it in one click: paste a name or phrase and switch instantly between UPPERCASE, lowercase, Title Case, Sentence case, camelCase, PascalCase, snake_case, kebab-case and CONSTANT_CASE.
The four styles side by side, straight out of our own case converter:
| Input | camelCase | PascalCase | snake_case | kebab-case |
|---|---|---|---|---|
user first name | userFirstName | UserFirstName | user_first_name | user-first-name |
HTTP response code | httpResponseCode | HttpResponseCode | http_response_code | http-response-code |
iPhone 15 Pro Max | iPhone15ProMax | IPhone15ProMax | i_phone_15_pro_max | i-phone-15-pro-max |
XMLHttpRequest | xmlhttpRequest | XmlhttpRequest | xmlhttp_request | xmlhttp-request |
A few tips
- Be consistent within a project. The specific convention matters less than applying it uniformly.
- Follow the language’s idiom. Writing
snake_casein JavaScript (orcamelCasein Python) signals that code doesn’t belong. - Use CONSTANT_CASE sparingly — only for genuine constants and environment variables.
Get the style right and your code reads like it belongs. Try the free case converter next time you need to reshape a name.
Two of those rows carry a warning. HTTP response code becomes httpResponseCode — the acronym is flattened to http, which is what most style guides actually want in an identifier, but it is a decision, not a neutral transformation. And iPhone 15 Pro Max becomes i_phone_15_pro_max: the converter splits at the case transition inside iPhone, giving a stray leading i_. Mechanical re-casing is reliable for ordinary words (user-first-name) and unreliable the moment acronyms or brand names are involved — so run it, then read it.