🔠 camelCase, snake_case & Other Naming Conventions

When to use each naming style

The same identifier can be written as camelCase, PascalCase, or snake_case depending on the language or context you're in. This article covers the naming conventions you'll run into in code, which language or context each one conventionally belongs to, and why keeping them consistent matters.

Naming Conventions Commonly Used in Code

Taking the same concept — "user login count" — as an example, here's how it looks in each style:

The names differ, but the purpose is the same: express a multi-word concept as a single valid identifier (a variable name, filename, or URL — none of which can contain spaces) while still keeping the word boundaries visible.

Which Language or Context Uses Which

Each style has settled into being the convention for a specific language or context. JavaScript, Java, and C# use camelCase for variable and function names (e.g. getUserName) and PascalCase for class names (e.g. UserAccount). Python and Ruby go the other way for variables and functions, using snake_case (e.g. get_user_name), while still following PascalCase for class names. kebab-case is the de facto standard for CSS class names (.user-card), HTML attributes (data-user-id), and URL paths (/guides/case-styles/), because hyphens are treated more naturally than underscores in CSS and URL syntax. Finally, CONSTANT_CASE is used across languages whenever you want the naming itself to signal "this is a constant that doesn't change" (e.g. MAX_RETRY_COUNT, API_BASE_URL).

Why Consistency Matters

No single style is objectively better, but mixing them within one project causes real problems. If the same kind of value is written userId in one place and user_id in another, every reader has to stop and remember which spelling is used where, and autocomplete or search for the identifier becomes unreliable. Linters and formatters like ESLint and Prettier typically ship rules that enforce a single naming convention project-wide, because standardizing on one style reduces code review time and mistakes, not just improves readability. This matters even more in projects that span multiple languages — for example, an API response that maps a Python backend's snake_case field names to a JavaScript frontend's camelCase — where you need to know exactly where the convention switches to avoid bugs. One task that comes up constantly when standardizing naming is a plain uppercase/lowercase conversion. For example, turning user_login_count (which already has its words separated by underscores) into CONSTANT_CASE only requires uppercasing the whole string — and that kind of case conversion can be handled instantly with a text tool.

🔠 Try it yourself with the tool

camelCase, snake_case & Other Naming Conventions — When to use each naming style

More Guides

🔁
How to Find a Domain's IP Address
Find the real server IP a domain points to
🛰️
How to Check DNS Propagation (What Is TTL?)
Understand TTL and check propagation after a nameserver change
📡
The Easiest Way to Find Your IP Address
Public vs private IP, and how to check yours
📐
CIDR Notation and How to Calculate a Subnet Mask
Convert CIDR notation like /24 into a subnet mask
🩺
How to Check an SSL Certificate's Expiration Date
Check a certificate's expiry without opening a browser
🪪
Understanding JWT Structure and How to Decode It
The Header, Payload & Signature — explained
🗝️
How to Create an Apache .htpasswd File for Basic Auth
Generate an APR1-MD5 hashed .htpasswd file
🔑
What Makes a Strong Password (and How to Generate One)
Length, character sets & entropy explained
🔐
What Is Base64 Encoding and When to Use It
Why it's used in email attachments & data URIs
📘
Using a JSON Formatter to Read API Responses
Turn minified JSON into something readable
🗓️
How to Convert a Unix Timestamp to a Date
Turn seconds-since-1970 into a readable date
🗃️
How to Format Messy SQL Queries
Break a one-line SQL statement into readable clauses
🎨
Converting Between HEX, RGB, and HSL Color Codes
The difference between the three formats
🆚
How to Compare Two Text Files (Diff Checker)
Quickly spot differences between two versions