camelCase vs snake_case vs kebab-case: Naming Conventions Explained

Published 2026-05-16

Every programmer eventually wonders: should this variable be userName, user_name, or user-name? These are not random style choices — each convention has a name, a history, and a set of languages and contexts where it is the norm. Getting them right makes your code look native to the ecosystem you are working in. Here is the complete map.

The four main conventions

  • camelCase — first word lowercase, each following word capitalized: userName, maxRetryCount. Named because the capital letters look like a camel's humps.
  • PascalCase (also called UpperCamelCase) — like camelCase but the first letter is also capitalized: UserName, HttpClient.
  • snake_case — all lowercase, words joined by underscores: user_name, max_retry_count.
  • kebab-case (also called dash-case) — all lowercase, words joined by hyphens: user-name, main-content. Named because the words look skewered like a kebab.

There is also SCREAMING_SNAKE_CASE — snake_case in all capitals (MAX_SIZE, API_KEY) — reserved almost everywhere for constants.

Which convention goes where

The conventions are not interchangeable; communities have settled on strong norms:

  • JavaScript / TypeScript: camelCase for variables and functions, PascalCase for classes and React components.
  • Python: snake_case for variables and functions, PascalCase for classes, SCREAMING_SNAKE_CASE for constants (this is the PEP 8 standard).
  • Ruby: snake_case for methods and variables, PascalCase for classes.
  • Go: PascalCase for exported names, camelCase for unexported ones — capitalization is actually meaningful to the compiler.
  • CSS: kebab-case for class names and custom properties (--main-color).
  • URLs and file names: kebab-case, because hyphens are read as word separators by search engines and are easy to read in links.
  • Database columns: usually snake_case.

Why hyphens cannot be used in code

You may wonder why kebab-case is fine for CSS and URLs but never for variables. The reason is that most programming languages interpret the hyphen as the minus operator — user-name would be parsed as "user minus name." That is why code uses camelCase or snake_case (both made only of letters, digits, and underscores) while markup and URLs, which have no arithmetic, can use hyphens freely.

Converting between conventions

Renaming identifiers from one convention to another by hand is tedious and error-prone, especially across a large file or when porting code between languages. The mechanical rules are:

  • To camelCase / PascalCase: remove separators, capitalize the letter after each removed separator.
  • To snake_case / kebab-case: insert a separator before each capital letter, then lowercase everything.

Edge cases — acronyms like HTTPServer, leading capitals, numbers — are where manual conversion tends to slip. A converter handles them consistently.

Consistency beats correctness

If there is one rule above all others, it is this: match the surrounding code. A "wrong" convention used consistently is far more readable than the "right" one applied haphazardly. When you join a project, adopt its conventions even if they differ from your personal preference. Linters and formatters can enforce this automatically.

Need to switch some text between cases right now? Paste it into the converter below and get UPPERCASE, lowercase, Title Case, camelCase, PascalCase, snake_case, and kebab-case in one click.

Related tool: Case Converter — Convert text between UPPER, lower, Title, camelCase, snake_case, and more.
Copied!