Text Tools4 min read|HEHaeun

firstName or first_name? The Naming Convention Guide That Ends the Debate

camelCase, snake_case, PascalCase, kebab-case — every team argues about it at some point. Here's what each format actually means, what the community conventions say per language, and how to convert between them without making everyone angry.

It usually happens around the third week of a new project. Someone opens a pull request, and buried in the review comments is a thread that somehow lasts longer than the actual feature discussion: 'We're using camelCase for variables.' 'But Python convention is snake_case.' 'Can we just pick one?' I've seen this go twenty comments deep. This guide is what should have been linked instead.

What You'll Learn in This Post

  • What each case format means and where each one belongs by language and context
  • A comparison table covering all major formats with real examples
  • API naming conventions, SEO Title Case rules, and how to convert instantly

The Six Case Formats, Defined

There are more naming conventions than most people realize. The common ones have names that describe their appearance, but what matters is understanding exactly when each is expected — not just in one language, but across the whole stack.

FormatExampleAlso Known AsWhere It's Used
camelCasefirstNamelower camel caseJS/TS variables, Java fields, JSON keys (common)
PascalCaseFirstNameupper camel case, StudlyCaseClasses, React components, C# identifiers, TypeScript types
snake_casefirst_nameunderscore notationPython vars/functions, Ruby, PostgreSQL columns, Rust
SCREAMING_SNAKE_CASEFIRST_NAMEUPPER_SNAKE_CASE, MACRO_CASEConstants, environment variables, C/C++ macros
kebab-casefirst-namespinal-case, hyphen-caseCSS classes, HTML attributes, URL slugs, CLI flags
Title CaseFirst Namestart caseArticle headings, page titles, proper nouns, UI labels

Language-by-Language: What the Community Actually Does

The frustrating thing about naming conventions is that they're not universal. What's correct in JavaScript is wrong in Python. What's idiomatic in CSS looks broken in SQL. Here's a quick reference that covers the main ecosystems:

// JavaScript / TypeScript
const firstName = 'Alice';          // camelCase — variables
class UserProfile { }               // PascalCase — classes
const MAX_RETRIES = 3;              // SCREAMING_SNAKE — constants
type ApiResponse = { ... };         // PascalCase — types and interfaces

# Python
first_name = 'Alice'               # snake_case — variables and functions
class UserProfile:                  # PascalCase — classes
MAX_RETRIES = 3                    # SCREAMING_SNAKE — module-level constants

/* CSS */
.user-profile { }                  /* kebab-case — class names */
--primary-color: #3B82F6;          /* kebab-case — custom properties */

-- SQL
CREATE TABLE user_profiles (        -- snake_case — table names
  first_name VARCHAR(50),           -- snake_case — column names
  PRIMARY KEY (id)
);

// Go
func GetUserProfile() { }           // PascalCase — exported
func getUserProfile() { }           // camelCase — unexported
💡

The rule that saves most arguments

Follow the idiomatic convention of the language you're writing in. If a language has a widely adopted style guide (Python has PEP 8, JavaScript has Airbnb, Go has gofmt), defer to that. The goal isn't to be right — it's to write code that any experienced developer in that ecosystem can read without friction.

Try this tool now:

Case Converter

The API Naming Problem (and the Best Solution)

APIs are where naming convention debates get genuinely complicated, because your backend and frontend might use different languages. A Python Django backend naturally uses snake_case. A JavaScript React frontend expects camelCase. When you define your API response, which wins?

The industry has basically split into two camps. The JSON:API and OpenAPI communities tend to favor camelCase for JSON keys, arguing it's more natural for JavaScript consumers. Python and Ruby developers often push for snake_case because it matches their backend models directly. GraphQL schemas almost always use camelCase for field names.

  • REST APIs: No universal standard, but camelCase has broader adoption across frontend-heavy teams. snake_case is common in Python and Ruby-backed APIs.
  • GraphQL: camelCase for field names is near-universal (firstName, not first_name)
  • gRPC / Protocol Buffers: snake_case in .proto files, camelCase generated in JS output
  • Database to API mapping: Use a serialization layer (like Pydantic's alias_generator) to translate snake_case DB columns to camelCase JSON keys automatically
  • Environment variables: Always SCREAMING_SNAKE_CASE — this is universal and enforced by most platforms
⚠️

Inconsistent API naming across endpoints causes bugs

If some endpoints return firstName and others return first_name for the same field, frontend engineers will write brittle workarounds. Once an API is public, renaming keys is a breaking change. Establish your convention before the first endpoint ships, document it in an API style guide, and use a linter (like Spectral for OpenAPI) to enforce it.

SEO and Title Case: More Nuanced Than You Think

For content writers and marketing teams, the main battleground is Title Case vs. Sentence case for headings and page titles. Title Case capitalizes the first letter of most words (with exceptions for articles and prepositions under 4 letters). Sentence case only capitalizes the first word and proper nouns.

The SEO implications are real but often misunderstood. Google reads and ranks both equally well — the difference is entirely about brand voice and UX. Title Case signals authority and formality (common in journalism and legal writing). Sentence case feels more conversational and modern (Google, Apple, Notion, and Linear all use it in their interfaces). The key is choosing one and being consistent across your entire site.

  • Title Case: 'How to Calculate Compound Interest in Python' — formal, editorial
  • Sentence case: 'How to calculate compound interest in Python' — modern, conversational
  • ALL CAPS in titles: Avoid — it reads as shouting and scores poorly in user testing
  • kebab-case for URL slugs: Always — spaces become %20, hyphens are human-readable and preferred by Google
  • PascalCase in filenames: Common in JavaScript/React projects for component files (UserProfile.tsx)

Converting Between Cases: Faster Than You Think

Manual conversion between cases is the kind of task that sounds simple but gets tedious fast — especially when you have 50 column names from a database schema that need to become camelCase JSON keys. The algorithm is always the same: split on delimiters (spaces, underscores, hyphens, capital letters), then reassemble in the target format. A good converter tool handles all of this instantly.

Frequently Asked Questions

Does using the wrong case in JavaScript actually break anything?

It depends. Variable naming is flexible in JavaScript — firstName and first_name are both valid. The issue is ecosystem consistency and code review standards. However, in specific contexts, case is enforced: React component names must be PascalCase (lowercase names are treated as HTML elements), and class names must be exact strings matching your CSS. Wrong case in those contexts causes real bugs.

What case format should I use for REST API JSON keys?

camelCase is the most widely accepted convention for JSON keys in REST APIs, especially in JavaScript-heavy ecosystems. It aligns with how JavaScript developers naturally access object properties. If your backend is Python or Ruby, use a serialization layer to auto-convert your snake_case models to camelCase output. Never mix conventions across endpoints — that's worse than either choice.

Is kebab-case valid in JavaScript?

Not for variable names — JavaScript doesn't allow hyphens in identifiers because they're interpreted as minus signs. obj.first-name would be parsed as subtraction. However, kebab-case is completely valid and preferred for CSS class names, HTML data attributes (data-user-id), and URL slugs.

What's the difference between PascalCase and camelCase?

Both join words without separators, but PascalCase capitalizes the first letter of every word including the first one (FirstName), while camelCase keeps the first letter lowercase (firstName). PascalCase is used for class names, types, and constructors. camelCase is used for variables, functions, and method names.

How do I enforce naming conventions across a team?

ESLint with the camelcase or naming-convention rules handles JavaScript/TypeScript. Pylint or Flake8 with appropriate plugins covers Python. Stylelint handles CSS. For APIs, Spectral with custom rules can lint OpenAPI documents. Add these to your CI pipeline so violations are caught before code review, not during it.

Case Converter

Instantly convert any text between camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE_CASE, and Title Case. Bulk convert entire variable lists in one click.

Open Case Converter

Try the tools from this article

HE

Haeun

Content editor. Making everyday tool guides easy and fun to follow.

Found this helpful? Get new guide alerts

No spam. Unsubscribe anytime. · By subscribing, you agree to our Privacy Policy.

You might also like

84+

Tools available

100+

Blog articles

English & 한국어

Languages

Bookmark this page! We add new free tools every week.