·8 min read·Text Processing

camelCase vs snake_case vs kebab-case: Naming Convention Guide

Learn when to use camelCase, snake_case, kebab-case, PascalCase, and CONSTANT_CASE. Covers conventions for JavaScript, Python, CSS, SQL, APIs, and file naming.

Try our free Case Converter

Convert between 12+ case formats: camelCase, snake_case, kebab-case, PascalCase, and more.

Open Tool

Why Naming Conventions Matter

Naming conventions are one of the most important decisions in software development. They affect readability, maintainability, onboarding speed, and even bug frequency. A codebase with consistent naming is dramatically easier to navigate than one where every file and variable follows a different pattern.

Conventions exist because different languages, frameworks, and ecosystems have converged on specific styles over decades. Python developers expect snake_case. JavaScript developers expect camelCase. CSS developers expect kebab-case. Breaking these expectations creates friction for every developer who reads your code.

This guide covers every major naming convention, explains where each one is used, and provides a quick-reference table mapping conventions to languages. If you need to convert between formats, our Case Converter handles 12+ case formats instantly.

camelCase and PascalCase

camelCase

In camelCase, the first word is lowercase and each subsequent word starts with an uppercase letter. No separators are used. It is named after the "humps" created by the capital letters.

// camelCase examples
firstName
getUserById
isAuthenticated
maxRetryCount
onClick
innerHTML

Where it is used: JavaScript/TypeScript variables, functions, and methods. Java variables and methods. JSON property names in many APIs. Swift and Kotlin local variables. It is by far the most common convention in the JavaScript ecosystem.

PascalCase (UpperCamelCase)

PascalCase is like camelCase but the first letter is also capitalized. It is sometimes called UpperCamelCase.

// PascalCase examples
UserProfile
HttpClient
StringBuilder
ReactComponent
GetUserById     // Go exported function

Where it is used:Class names in almost every language (JavaScript, TypeScript, Java, C#, Python). React component names. Go exported identifiers (functions, types, variables). TypeScript interfaces and type aliases. C# methods and properties. PascalCase signals "this is a type or constructor" in most ecosystems.

snake_case and CONSTANT_CASE

snake_case

In snake_case, all words are lowercase and separated by underscores. It is highly readable because spaces are replaced by a visible separator.

# snake_case examples
first_name
get_user_by_id
is_authenticated
max_retry_count
created_at

Where it is used: Python variables, functions, and modules (mandated by PEP 8). Ruby variables and methods. Rust variables and functions. PHP variables. Database column names. Elixir and Erlang. Many major APIs use snake_case for JSON fields, including the GitHub API, Stripe API, and Twitter API.

CONSTANT_CASE (SCREAMING_SNAKE_CASE)

CONSTANT_CASE is snake_case with all letters uppercase. It is used universally for constants and environment variables.

// CONSTANT_CASE examples
MAX_RETRY_COUNT
API_BASE_URL
DATABASE_URL
NODE_ENV
HTTP_STATUS_OK

Where it is used: Constants in JavaScript, Python, Java, C, C++, Rust, and nearly every language. Environment variables (DATABASE_URL, NODE_ENV). Preprocessor macros in C/C++. Enum values in many languages. If a value should never change, use CONSTANT_CASE.

kebab-case and dot.case

kebab-case

In kebab-case, all words are lowercase and separated by hyphens. It is named after the pieces of food on a kebab skewer.

/* kebab-case examples */
user-profile
my-component
font-family
background-color
text-decoration-line

Where it is used: CSS property names and class names. HTML attributes (data-user-id). URL slugs and paths (/api/user-profiles). npm package names. File names on Linux. Lisp and Clojure identifiers. Kebab-case cannot be used for variable names in most programming languages because the hyphen is interpreted as a minus operator.

dot.case

In dot.case, words are lowercase and separated by periods.

// dot.case examples
com.example.myapp
java.util.ArrayList
app.config.database
user.profile.settings

Where it is used: Java and Android package names. Configuration file keys (YAML, TOML, properties files). Redis keys. Object property access paths. Spring Boot configuration properties. It is less common than other conventions but important in specific domains.

Conventions by Language and Framework

The following table summarizes which naming convention each language and framework expects. Following these conventions ensures your code feels natural to other developers in that ecosystem. You can use our Case Converter to quickly switch between formats, and our Word Counter to analyze identifier length.

Language / ContextVariables & FunctionsClasses / TypesConstants
JavaScript / TypeScriptcamelCasePascalCaseCONSTANT_CASE
Pythonsnake_casePascalCaseCONSTANT_CASE
JavacamelCasePascalCaseCONSTANT_CASE
GocamelCase (unexported)PascalCase (exported)PascalCase / camelCase
Rustsnake_casePascalCaseCONSTANT_CASE
Rubysnake_casePascalCaseCONSTANT_CASE
C# / .NETcamelCase (local)PascalCasePascalCase
CSSkebab-casekebab-case--kebab-case (vars)
HTMLkebab-case (attributes)----
SQL / Databasessnake_casesnake_case (tables)CONSTANT_CASE

React and Vue: React components must use PascalCase (UserProfile), while props and state use camelCase. Vue uses PascalCase for components in script but kebab-case in templates (<user-profile />). Angular uses camelCase for properties and kebab-case for selectors.

Go is unique: In Go, the case of the first letter determines visibility. PascalCase identifiers (GetUser) are exported (public), while camelCase identifiers (getUser) are unexported (private). Go does not use CONSTANT_CASE -- constants follow the same capitalization rules as other identifiers.

API and Database Naming

REST API URLs

REST API endpoint URLs should use kebab-case with lowercase letters. URLs are case-sensitive on most servers, and kebab-case is the most readable format in a browser address bar. Use plural nouns for resource collections:

# Good: kebab-case URLs
GET  /api/user-profiles
POST /api/user-profiles
GET  /api/user-profiles/123/billing-addresses

# Bad: other conventions in URLs
GET  /api/userProfiles        (camelCase -- harder to read)
GET  /api/user_profiles       (snake_case -- unconventional)
GET  /api/UserProfiles        (PascalCase -- URLs should be lowercase)

JSON Response Fields

There is no universal standard for JSON field names. The two dominant conventions are camelCase (used by Google APIs, Microsoft Graph, and most JavaScript-first APIs) and snake_case (used by GitHub, Stripe, Twitter, and Ruby/Python-first APIs). Pick one and be consistent across your entire API:

// camelCase (JavaScript convention)
{
  "firstName": "Alice",
  "lastName": "Smith",
  "createdAt": "2026-05-11T10:00:00Z"
}

// snake_case (Python/Ruby convention)
{
  "first_name": "Alice",
  "last_name": "Smith",
  "created_at": "2026-05-11T10:00:00Z"
}

Database Column and Table Names

The overwhelming standard for relational databases (PostgreSQL, MySQL, SQLite) is snake_case for both table names and column names. Use plural snake_case for table names and singular snake_case for columns:

-- Database naming conventions
CREATE TABLE user_profiles (
  id            SERIAL PRIMARY KEY,
  first_name    VARCHAR(100) NOT NULL,
  last_name     VARCHAR(100) NOT NULL,
  email_address VARCHAR(255) UNIQUE NOT NULL,
  created_at    TIMESTAMP DEFAULT NOW(),
  is_active     BOOLEAN DEFAULT true
);

SQL is case-insensitive by default, but snake_case avoids the need for quoted identifiers. Avoid camelCase in database schemas -- it requires quoting in PostgreSQL ("firstName") and creates confusion when mapping between code and database layers.

File and Directory Naming

On Linux and macOS, file names are case-sensitive. On Windows, they are not. To avoid cross-platform issues, use kebab-case for files and directories in web projects. Many frameworks enforce this: Next.js route folders, npm package names, and Docker image names all use kebab-case.

# File naming conventions
user-profile.ts          (kebab-case -- recommended for files)
UserProfile.tsx          (PascalCase -- React component files)
user_profile.py          (snake_case -- Python modules)
USER_PROFILE.env         (CONSTANT_CASE -- environment files)

Frequently Asked Questions

Which naming convention should I use?
Follow the standard for your language or framework. JavaScript uses camelCase, Python uses snake_case, CSS uses kebab-case, Go uses PascalCase for exports. Consistency with community expectations matters more than personal preference. Check your language's official style guide (PEP 8 for Python, Effective Go, Airbnb JavaScript Style Guide).
Can I mix naming conventions in one project?
Yes, and it is common. JavaScript variables use camelCase, CSS classes use kebab-case, database columns use snake_case, and environment variables use CONSTANT_CASE -- all in the same project. The rule is to be consistent within each layer. A linter like ESLint or Pylint will enforce conventions automatically.
How do I convert between naming conventions?
Use our Case Converter tool at toolzip.xyz to instantly convert between 12+ formats including camelCase, snake_case, kebab-case, PascalCase, and CONSTANT_CASE. You can also use IDE extensions (Change Case for VS Code), or library functions like lodash's _.camelCase() and _.snakeCase() in JavaScript.
What convention should REST API endpoints use?
Use kebab-case for URLs (e.g., /api/user-profiles) and either camelCase or snake_case for JSON response fields. Google and Microsoft use camelCase in JSON; GitHub, Stripe, and Twitter use snake_case. Pick one and document it in your API style guide. Never mix conventions within the same API.

Convert Case Formats Now

Convert between camelCase, snake_case, kebab-case, PascalCase, CONSTANT_CASE, and more. Free, private, runs in your browser.

Open Case Converter

Related Tools