tooldura

Text Tools

camelCase, snake_case, kebab-case: Which Case Goes Where

T
tooldura editorial
7 min readUpdated August 5, 2026Open tool →

Case conventions look like bikeshedding until you work in a codebase where nobody agreed on one. Then a search for getUserId misses get_user_id, a CSS class silently fails to match, and a URL that worked on your laptop returns 404 on the server. The conventions exist because the alternative costs real time.

The Six You Will Actually Meet

Each convention solved a specific problem when it was introduced, and most are still in use for that reason.

1

camelCase

First word lowercase, every following word capitalised: userAccountId. Standard for variables and functions in JavaScript, Java, Swift and C#. It reads quickly at a glance and costs no extra characters.

2

PascalCase

Every word capitalised, including the first: UserAccountId. Reserved almost universally for types, classes and components. The distinction from camelCase is what lets you tell a class from a variable without context.

3

snake_case

All lowercase, underscores between words: user_account_id. The convention in Python, Ruby, Rust and most SQL databases. Easier to read for long names, which is why it dominates where names get descriptive.

4

kebab-case

All lowercase, hyphens between words: user-account-id. Required in URLs and CSS class names because both treat the hyphen as an ordinary character while underscores can be awkward. Never valid as an identifier in most languages, since the hyphen parses as subtraction.

5

SCREAMING_SNAKE_CASE

All uppercase with underscores: MAX_RETRY_COUNT. Signals a constant in nearly every language, and the standard for environment variables everywhere.

6

Title Case

Capitalised words for prose headings: Which Case Goes Where. Not a programming convention at all, and the rules differ by style guide, which is the source of most disagreement about it.

What Each Language Expects

Following the local convention matters more than any argument about which is better. Consistency with the ecosystem beats personal preference.

ContextVariables and functionsTypes and classesConstants
JavaScript / TypeScriptcamelCasePascalCaseSCREAMING_SNAKE
Pythonsnake_casePascalCaseSCREAMING_SNAKE
Rubysnake_casePascalCaseSCREAMING_SNAKE
GocamelCase (private)PascalCase (exported)PascalCase or camelCase
Rustsnake_casePascalCaseSCREAMING_SNAKE
Java / C#camelCasePascalCaseSCREAMING_SNAKE
SQLsnake_casesnake_casen/a
CSSkebab-casekebab-casekebab-case (custom properties)
URLs and file pathskebab-casekebab-casen/a
Environment variablesSCREAMING_SNAKEn/aSCREAMING_SNAKE

The Case That Changes Behaviour

In most languages, case is a convention you can break without consequence beyond annoying your colleagues. Go is the exception worth knowing about.

In Go, capitalisation controls visibility. An identifier starting with an uppercase letter is exported from its package and visible to other packages. A lowercase one is not. Renaming `userCount` to `UserCount` does not just change style, it changes the public API of your package.

This catches people who arrive from languages with explicit `public` and `private` keywords, because nothing in the syntax announces that a capital letter is doing access control. If a Go symbol suddenly stops compiling elsewhere after a rename, this is almost always why.

🔤

Title Case rules are not universal

AP style capitalises words of four letters or more, so it writes "Which Case Goes With Data". Chicago capitalises all words except articles, coordinating conjunctions and prepositions regardless of length, giving "Which Case Goes with Data". Neither is wrong. Pick one, write it into your style guide, and stop relitigating it in code review.

The Acronym Problem

Every convention breaks down on acronyms, and every large codebase has an inconsistent mix as a result.

Is it `parseHTTPResponse` or `parseHttpResponse`? Is the identifier `userID` or `userId`? Both appear in major standard libraries, sometimes in the same one.

The rule that causes least trouble is to treat acronyms as ordinary words: capitalise only the first letter, giving `parseHttpResponse` and `userId`. This keeps case conversion reversible, which matters more than it sounds. A tool converting `userID` to snake_case has to guess whether you meant `user_i_d` or `user_id`, and it will sometimes guess wrong. `userId` converts to `user_id` unambiguously every time.

Google's Java style guide and Microsoft's .NET guidelines both landed on this rule for the same reason. The exception is Go, whose own conventions keep acronyms fully capitalised, so `userID` is idiomatic there.

Convert between cases instantly

UPPER, lower, Title, Sentence, camelCase, snake_case and kebab-case.

Open Case Converter →

Why URLs Use Hyphens

Google has stated directly that hyphens are treated as word separators in URLs while underscores are not, or at least not reliably. A page at `/word-counter-guide` is understood as three words. The same path with underscores has historically been read as one long token.

The practical difference is smaller than it was, because modern search engines handle both better than they did in 2010. But hyphens remain the safer choice, they read better to humans scanning a URL, and every major CMS defaults to them. There is no upside to underscores in a path.

Case matters here too. Paths on Linux servers are case-sensitive, so `/About` and `/about` are different pages. Serving both is a duplicate content problem, and linking to one while your canonical points at the other quietly splits your ranking signals. Lowercase everything and redirect the variants.

Frequently Asked Questions

Related Tools

Keep Reading