All guides
Developer5 min read

camelCase, snake_case, kebab-case: Why Each Convention Exists

Naming conventions are not arbitrary style preferences — each solves a specific technical constraint. A guide to which goes where.

Programming languages cannot have spaces in identifiers, so every language needed a way to join multi-word names. Different communities settled on different answers, and those answers hardened into conventions that now carry real meaning — using the wrong one marks code as foreign even when it runs perfectly.

camelCase

First word lowercase, subsequent words capitalised: userName, calculateTotal. Standard for variables and functions in JavaScript, Java, C#, Swift, and Kotlin. In JavaScript it is effectively universal — built-in APIs like getElementById and addEventListener follow it, so matching keeps your code consistent with the platform.

PascalCase

Every word capitalised, including the first: UserAccount, HttpClient. Used for classes and types across most of the same languages, which creates a genuinely useful signal: seeing a capital initial tells you the identifier is a type rather than a value. React extended this to components, where it is load-bearing rather than stylistic — JSX treats lowercase tags as HTML elements and capitalised ones as components, so the casing changes the behaviour.

snake_case

Lowercase words joined by underscores: user_name, calculate_total. The convention in Python, Ruby, Rust, and most SQL databases. Its advantage is readability — the underscore is a visually clearer separator than a case change, which matters in languages that are case-insensitive.

That last point is not trivial. SQL identifiers are case-insensitive in many databases, so UserName and username are the same column. snake_case sidesteps the ambiguity entirely, which is why it dominates database schema design.

SCREAMING_SNAKE_CASE

Uppercase with underscores: MAX_RETRIES, API_BASE_URL. Reserved almost everywhere for constants and environment variables. The convention is strong enough that seeing it signals do not modify this, even in languages with no enforced immutability.

kebab-case

Lowercase words joined by hyphens: user-profile, main-content. Used for URLs, CSS class names, and HTML attributes. It cannot be used for identifiers in most languages, because the hyphen parses as subtraction — user-name would be read as user minus name.

For URLs this is more than convention. Search engines treat hyphens as word separators and underscores as word joiners, so my-blog-post is read as three words while my_blog_post may be read as one. That has a direct effect on how a page is understood.

Converting between them

Data crossing system boundaries usually needs converting: a Python API returning snake_case JSON consumed by a JavaScript frontend expecting camelCase, or database columns mapped to object properties. Doing this by hand across a long list is tedious and error-prone, which is exactly the kind of job worth automating.

One caution: acronyms are where automated conversion gets inconsistent. HTTPSConnection, HttpsConnection, and httpsConnection are all defensible readings, and different tools disagree. Check those cases by hand.

Mavertex's Case Converter handles all of these conversions on text of any length, running entirely in your browser.

Try it yourself

Free, browser-based, no sign-up.

Open Case Converter