CyberCodeLab logo — neon green lab flask with terminal symbolCyberCodeLab
Three panels comparing camelCase used in JavaScript, snake_case used in Python, and kebab-case used in CSS and URLs, with example identifiers

2026-07-16

camelCase vs snake_case vs kebab-case: Naming Conventions

camelCase, PascalCase, snake_case or kebab-case? See which naming convention each language expects — JavaScript, Python, CSS, URLs — with a reference table.

Quick answer: use camelCase for JavaScript and Java variables, snake_case for Python and SQL, PascalCase for classes and components, SCREAMING_SNAKE_CASE for constants, and kebab-case for URLs and CSS. The winning convention is whichever your language's community already uses — here's the full map.

Every programmer has typed a variable name, paused, and wondered: userName, user_name, or user-name? The answer isn't taste — nearly every language and ecosystem has already made the choice for you, and following it is one of the cheapest ways to make your code look professional.

Here's what each convention is, exactly where each one belongs, and the one rule that matters more than any of them.

The five conventions at a glance

ConventionExampleReads as
camelCasefirstNamefirst word lowercase, rest capitalized
PascalCaseFirstNameevery word capitalized
snake_casefirst_namelowercase, underscores
SCREAMING_SNAKE_CASEFIRST_NAMEuppercase, underscores
kebab-casefirst-namelowercase, hyphens

You can convert any text between all of these instantly with our free Case Converter — paste once, copy the version you need.

camelCase — the JavaScript world

Variables, functions and properties in JavaScript, TypeScript, Java, Swift and Kotlin use camelCase: getUserData(), isLoggedIn, maxRetryCount. JSON API fields most commonly follow it too, since so many APIs are consumed by JavaScript.

The name comes from the capital letters poking up like a camel's humps. Its advantage is compactness — no separator characters at all — at the cost of slightly harder reading when words pile up (getHTTPSConnectionURL is nobody's friend; prefer getHttpsConnectionUrl).

PascalCase — for types and classes

PascalCase is camelCase with the first letter capitalized, and it has one specific job in most languages: names of classes, types and componentsUserAccount, HttpClient, a React NavBar. In C# it goes further and covers methods too.

The capital first letter is a signal: this name is a type, not a value. That's why new userAccount() looks instantly wrong to an experienced reader.

snake_case — the Python world

Python, Ruby, Rust, PHP (functions) and virtually all SQL databases use snake_case for variables, functions and column names: first_name, calculate_total(), created_at. Studies on reading speed give a slight edge to snake_case — the underscore is a more visible word boundary than a capital letter — which fits Python's readability-first culture.

Its uppercase sibling, SCREAMING_SNAKE_CASE, means one thing almost everywhere: constantsMAX_RETRIES, API_BASE_URL. Seeing it tells the reader "this value never changes".

kebab-case — the web's convention

kebab-case (words-joined-by-hyphens, like a kebab skewer) rules everywhere the web is involved:

  • URLs: /blog/naming-conventions-guide
  • CSS classes and properties: .nav-bar, font-size, --brand-color
  • HTML attributes: data-user-id, aria-label
  • File names of web pages and npm package names: date-fns, react-dom

Why can't code use it? Because in almost every programming language the hyphen is the minus operator — first-name means "first minus name". That's also exactly why the web adopted it: URLs and CSS don't do arithmetic.

The SEO angle: Google's own guidance recommends hyphens over underscores in URLs — hyphens are treated as word separators, so /word-counter is understood as "word counter", while /word_counter may be read as one token. For slugs, kebab-case isn't a style choice; it's the correct answer.

What each language expects

ContextConvention
JavaScript / TypeScript variables & functionscamelCase
JS/TS classes, React componentsPascalCase
Python variables & functionssnake_case
Python classesPascalCase
Constants (almost everywhere)SCREAMING_SNAKE_CASE
CSS classes, custom propertieskebab-case
URLs & file slugskebab-case
SQL tables & columnssnake_case
Environment variablesSCREAMING_SNAKE_CASE

The rule that beats all conventions

Consistency wins. A codebase that uses snake_case everywhere is easier to work in than one that mixes camelCase and snake_case "correctly" across a blurry boundary. Follow the language's convention for new code; follow the existing style when editing someone else's — and let a linter (ESLint, Pylint, RuboCop) enforce it so nobody wastes review time on it.

The painful spot is the seams: a Python API sending snake_case JSON to a JavaScript frontend expecting camelCase. Pick one at the API boundary, document it, and convert in one place — not ad-hoc in every file.

Frequently asked questions

Which is best — camelCase or snake_case? Neither is objectively better; readability studies slightly favour snake_case while camelCase is more compact. The real answer is: use what your language's community uses — camelCase in JavaScript, snake_case in Python — so your code reads like everyone else's.

Why do URLs use hyphens instead of underscores? Search engines treat a hyphen as a word separator, so json-formatter is indexed as two words. Hyphens are also visible even when a link is underlined, while underscores disappear under the underline. Use kebab-case for every slug.

What is Title Case then? Title Case Capitalizes Each Word With Spaces — it's for human-facing text (headlines, button labels), not identifiers. Our Case Converter handles it alongside the programming cases, including proper handling of small words.

How do I rename a whole project from one convention to another? Don't do it by hand — use your IDE's rename-symbol refactoring (which updates all references), convert individual strings with a case converter, and change one convention per commit so reviews stay readable.

Next time you pause over userName vs user_name, check the table above — the ecosystem already decided, and going along with it is free.