camelCase, snake_case, kebab-case: Who Uses What

By The UtilCraft team · 3 min read ·

Every programming community settled on its own way of squeezing several words into one identifier. None of them is objectively better, but mixing them inside one codebase is a reliable source of friction and bugs. Here's who uses what, where the conventions came from, and how to convert between them without tripping over acronyms.

The five main styles

NameExample
camelCaseuserAccountId
PascalCase (UpperCamelCase)UserAccountId
snake_caseuser_account_id
SCREAMING_SNAKE_CASE (constant case)USER_ACCOUNT_ID
kebab-caseuser-account-id

Why not just use spaces? Because almost every programming language uses whitespace to separate tokens, and many treat - as subtraction. That rules out kebab-case in most languages, which is why it lives mainly in URLs, CSS and file names.

Who uses what

Language / contextVariables & functionsTypes & classesConstants
JavaScript / TypeScriptcamelCasePascalCaseSCREAMING_SNAKE or camelCase
Java, KotlincamelCasePascalCaseSCREAMING_SNAKE
C#camelCase (locals), PascalCase (methods, properties)PascalCasePascalCase
Pythonsnake_casePascalCaseSCREAMING_SNAKE
Rubysnake_casePascalCaseSCREAMING_SNAKE
Rustsnake_casePascalCaseSCREAMING_SNAKE
GocamelCase (private) / PascalCase (exported)PascalCaseSame as variables
PHP (PSR)camelCasePascalCaseSCREAMING_SNAKE
SQLsnake_case for tables and columns is the most common convention
CSSkebab-case for classes and custom properties
URLs, file names, CLI flagskebab-case
Environment variablesSCREAMING_SNAKE_CASE

Go is the interesting one: capitalisation isn't just style there, it's semantics. A name starting with an uppercase letter is exported from its package; a lowercase one is private.

A little history

snake_case is old, common in C and Unix from the start (str_len-style names were everywhere) and later adopted by Python's PEP 8 and Ruby. camelCase took hold through Smalltalk and Pascal-family languages, then spread to the mainstream with Java in the mid-1990s, which JavaScript copied. kebab-case comes from Lisp, where hyphens in names were normal, and from the web, where URLs and CSS needed something readable that wasn't a space.

Which is more readable?

There's some eye-tracking research comparing the two. A 2010 study by Sharif and Maletic found participants recognised underscore-separated identifiers somewhat faster, while earlier work found experienced camelCase users caught up with practice. The honest conclusion is that familiarity wins. Follow the convention of the language and codebase you're in; consistency matters far more than the choice itself.

The hard part: acronyms

How do you write "HTTP request ID" in camelCase? Three common answers:

  • httpRequestId: treat acronyms as ordinary words. Recommended by Google's Java and JavaScript style guides and by Microsoft's .NET guidelines for acronyms longer than two letters.
  • HTTPRequestID: keep acronyms uppercase. Go's style (ServeHTTP, userID) and older Apple APIs.
  • XMLHttpRequest: a famous inconsistency, with one acronym upper and one not, frozen into the web platform forever.

The first style is the easiest to convert reliably, because word boundaries stay visible. With HTTPRequestID, a converter has to guess that "HTTPR" splits as HTTP + R…, which it can only do by noticing where an uppercase run is followed by a lowercase letter.

Converting between conventions

Conversion comes up constantly at boundaries: a Python API returning created_at to a JavaScript client that wants createdAt, a database column becoming a Go struct field, a config key becoming an environment variable. Some advice:

  • Convert at the boundary, once.Most serialisation libraries can do it automatically (for example Jackson's naming strategies, Pydantic aliases, or a camelcase-keysstep in JavaScript). Don't scatter manual renames through the code.
  • Watch out for digits. Is address2 in snake_case address2 or address_2? Pick one and be consistent, or round-trips will break.
  • Test round-trips. user_id → userId → user_id should be lossless. With acronyms and digits, it often isn't.

For one-off conversions, paste the identifier into our Text Case Converter. It splits on underscores, hyphens, spaces and camelCase humps, treats runs of capitals as acronyms (XMLHttpRequest → xml_http_request), and shows every style at once.

Tools used in this guide

Keep reading