String Case Conventions Guide: camelCase, snake_case, and More

By Suvom Das March 12, 2026 14 min read

1. Why Naming Conventions Matter

Naming conventions are among the most impactful yet underappreciated aspects of software development. Consistent naming makes code readable, maintainable, and professional. Inconsistent naming creates cognitive overhead, slows down code reviews, and introduces subtle bugs when developers misinterpret identifier meanings.

Every programming language, framework, and project has established naming conventions. These conventions evolved for practical reasons: they encode semantic information (is this a class or a variable? a constant or a function?), improve readability by creating visual patterns, and reduce the mental effort required to understand unfamiliar code.

Studies in software engineering have shown that developers spend significantly more time reading code than writing it. Consistent naming conventions reduce the time needed to comprehend code, identify bugs, and onboard new team members. They also minimize bikeshedding in code reviews -- when everyone follows the same conventions, naming debates disappear.

Beyond code, naming conventions extend to database schemas, API contracts, file structures, configuration keys, environment variables, and documentation. Understanding the conventions for each context is essential for professional software development.

2. Common Case Conventions

The software industry uses a variety of case conventions, each with specific use cases and advantages. Here is a comprehensive overview of every major convention.

camelCase (Lower Camel Case)

In camelCase, the first word is lowercase and subsequent words start with uppercase letters. No separators are used. The name comes from the "humps" created by the uppercase letters in the middle of the identifier.

firstName
getUserById
isAuthenticated
maxRetryCount
handleFormSubmit

camelCase is the dominant convention for variables, functions, methods, and parameters in JavaScript, TypeScript, Java, C#, Swift, Kotlin, Dart, and many other languages. It is compact, widely recognized, and reads naturally.

PascalCase (Upper Camel Case)

PascalCase is identical to camelCase except that the first word also starts with an uppercase letter. It is named after the Pascal programming language, which popularized this convention.

UserProfile
HttpClient
DatabaseConnection
FormValidator
LinkedList

PascalCase is the standard convention for class names, type names, interfaces, enums, and constructors across most programming languages. In C#, it is also used for method names and public properties.

snake_case (Lower Snake Case)

snake_case uses all lowercase letters with words separated by underscores. The name comes from the underscores "crawling" along the bottom of the text, resembling a snake.

first_name
get_user_by_id
is_authenticated
max_retry_count
handle_form_submit

snake_case is the standard for Python (PEP 8), Ruby, Rust, Elixir, and PHP. It is also widely used for database column names, SQL identifiers, and configuration file keys. Many developers find it highly readable because the underscores create clear word boundaries.

SCREAMING_SNAKE_CASE (Upper Snake Case)

SCREAMING_SNAKE_CASE uses all uppercase letters with underscore separators. It is also called UPPER_SNAKE_CASE, MACRO_CASE, or CONSTANT_CASE.

MAX_CONNECTIONS
API_BASE_URL
DEFAULT_TIMEOUT_MS
DATABASE_URL
HTTP_STATUS_OK

This convention is universally used for constants, macro definitions (C/C++), and environment variables across virtually all programming languages. The all-caps format immediately signals that the value should not be modified.

kebab-case (Dash Case)

kebab-case uses all lowercase letters with words separated by hyphens. The name refers to words being "skewered" together like food on a kebab stick. It is also called dash-case, lisp-case, or spinal-case.

first-name
get-user-by-id
is-authenticated
my-component
background-color

kebab-case cannot be used for identifiers in most programming languages because the hyphen is interpreted as the subtraction operator. It is primarily used for CSS class names, HTML attributes, URL slugs, CLI flags, npm package names, YAML/JSON configuration keys, and file names.

Other Conventions

Several additional conventions appear in specific contexts:

3. Language-Specific Conventions

Each programming language has its own established conventions, typically documented in official style guides. Following these conventions makes your code idiomatic and recognizable to other developers in that ecosystem.

JavaScript / TypeScript

// Variables and functions: camelCase
const userName = 'alice';
function getUserProfile(userId) { ... }

// Classes and types: PascalCase
class UserProfile { ... }
interface ApiResponse { ... }
type FormState = { ... };

// Constants: SCREAMING_SNAKE_CASE
const MAX_RETRIES = 3;
const API_BASE_URL = 'https://api.example.com';

// Enums (TypeScript): PascalCase name, PascalCase members
enum HttpStatus { Ok, NotFound, ServerError }

// Files: kebab-case (user-profile.ts, api-client.js)
// React components: PascalCase files (UserProfile.tsx)

Python

# Variables and functions: snake_case
user_name = 'alice'
def get_user_profile(user_id): ...

# Classes: PascalCase
class UserProfile: ...

# Constants: SCREAMING_SNAKE_CASE
MAX_RETRIES = 3
DATABASE_URL = 'postgresql://...'

# Modules/packages: snake_case (user_profile.py)
# Private/internal: leading underscore (_internal_method)
# Name mangling: double underscore (__private_attr)

Java

// Variables and methods: camelCase
String userName = "alice";
UserProfile getUserProfile(int userId) { ... }

// Classes and interfaces: PascalCase
public class UserProfile { ... }
public interface Serializable { ... }

// Constants: SCREAMING_SNAKE_CASE
public static final int MAX_RETRIES = 3;

// Packages: reverse domain, all lowercase (com.example.myapp)
// Enums: PascalCase name, SCREAMING_SNAKE members

Go

// Exported (public): PascalCase
func GetUserProfile(userID string) *UserProfile { ... }
type UserProfile struct { ... }

// Unexported (private): camelCase
func getUserFromDB(userID string) *user { ... }
var maxRetries = 3

// Packages: all lowercase, single word preferred (http, fmt, json)
// Constants: PascalCase (exported) or camelCase (unexported)
// Acronyms: keep uppercase (userID, httpURL, xmlParser)

Rust

// Variables and functions: snake_case
let user_name = "alice";
fn get_user_profile(user_id: u32) -> UserProfile { ... }

// Types and traits: PascalCase
struct UserProfile { ... }
enum HttpStatus { ... }
trait Serializable { ... }

// Constants: SCREAMING_SNAKE_CASE
const MAX_RETRIES: u32 = 3;
static DATABASE_URL: &str = "postgresql://...";

// Modules and crates: snake_case

CSS

/* Class names: kebab-case (BEM methodology) */
.user-profile { ... }
.user-profile__header { ... }
.user-profile--active { ... }

/* Custom properties: kebab-case with -- prefix */
:root {
  --primary-color: #326CE5;
  --font-size-lg: 1.125rem;
}

/* SCSS/Sass variables: kebab-case with $ prefix */
$primary-color: #326CE5;
$max-width: 1200px;

4. API and Data Format Conventions

API design requires careful consideration of naming conventions because the API contract is public and consumed by developers using different languages. There is no single "correct" convention, but consistency within an API is essential.

JSON APIs

JSON API fields commonly use camelCase (following JavaScript conventions) or snake_case (following Python/Ruby conventions). Major APIs are split: Google APIs, GitHub API v4 (GraphQL), and the OpenAPI specification tend to use camelCase, while the GitHub REST API, Twitter API, and many Ruby on Rails APIs use snake_case.

// camelCase (common in JavaScript-oriented APIs)
{
  "userId": 42,
  "firstName": "Alice",
  "createdAt": "2026-03-12T10:00:00Z"
}

// snake_case (common in Python/Ruby-oriented APIs)
{
  "user_id": 42,
  "first_name": "Alice",
  "created_at": "2026-03-12T10:00:00Z"
}

Database Schemas

SQL databases traditionally use snake_case for table and column names because SQL is case-insensitive by default and many databases normalize unquoted identifiers to uppercase or lowercase. Using snake_case avoids the need for quoting and works consistently across databases.

CREATE TABLE user_profiles (
  user_id     SERIAL PRIMARY KEY,
  first_name  VARCHAR(100) NOT NULL,
  last_name   VARCHAR(100) NOT NULL,
  created_at  TIMESTAMP DEFAULT NOW()
);

Environment Variables

Environment variables universally use SCREAMING_SNAKE_CASE across all operating systems and platforms. This convention is so deeply established that it is essentially mandatory.

DATABASE_URL=postgresql://localhost:5432/mydb
REDIS_HOST=127.0.0.1
API_SECRET_KEY=sk-abc123
NODE_ENV=production
MAX_UPLOAD_SIZE_MB=10

5. File and Directory Naming

File naming conventions vary by ecosystem and project type, but several patterns have emerged as best practices.

kebab-case is the most universally safe convention for file names. It works across all operating systems, is URL-friendly, and is easy to read. Many web projects, including Angular, Vue, and npm packages, use kebab-case for file names.

PascalCase is used for component files in React (UserProfile.tsx) and class files in Java (UserProfile.java) and C# (UserProfile.cs). The file name matches the primary class or component it contains.

snake_case is standard for Python modules (user_profile.py), Rust source files (user_profile.rs), and Ruby files (user_profile.rb).

Important considerations for file naming: avoid spaces (use hyphens or underscores instead), be consistent within a project, avoid special characters, keep names reasonably short, and remember that some file systems are case-sensitive (Linux) while others are not (macOS by default, Windows).

6. How Case Conversion Works

Converting between case conventions involves three fundamental steps: splitting the string into words, normalizing the words, and joining them using the target convention's rules.

Step 1: Word Splitting

The first and most complex step is identifying word boundaries in the source string. Different source conventions use different boundary markers:

// Splitting examples:
"getUserById"     -> ["get", "User", "By", "Id"]     (case transition)
"get_user_by_id"  -> ["get", "user", "by", "id"]     (underscore separator)
"get-user-by-id"  -> ["get", "user", "by", "id"]     (hyphen separator)
"GetUserByID"     -> ["Get", "User", "By", "ID"]     (case transition + acronym)
"XMLHttpRequest"  -> ["XML", "Http", "Request"]       (acronym handling)

Step 2: Normalization

After splitting, normalize all words to lowercase. This provides a clean starting point for applying the target convention's capitalization rules.

Step 3: Joining

Apply the target convention's rules to rejoin the words:

Words: ["get", "user", "by", "id"]

camelCase:              "getUserById"         (first word lowercase, rest capitalized)
PascalCase:             "GetUserById"         (all words capitalized)
snake_case:             "get_user_by_id"      (all lowercase, underscore separated)
SCREAMING_SNAKE_CASE:   "GET_USER_BY_ID"      (all uppercase, underscore separated)
kebab-case:             "get-user-by-id"      (all lowercase, hyphen separated)
Title Case:             "Get User By Id"      (all capitalized, space separated)
dot.case:               "get.user.by.id"      (all lowercase, dot separated)

7. Edge Cases and Gotchas

Case conversion seems simple but has several tricky edge cases that can cause bugs in automated conversions.

Acronyms and Abbreviations

Handling acronyms like "HTTP", "URL", "API", "XML", and "ID" is the most common source of inconsistency. Should "HTTPSConnection" become https_connection or h_t_t_p_s_connection? Should "userID" become user_id or user_i_d?

Most style guides recommend treating acronyms as single words. Go is a notable exception: it preserves acronym capitalization (userID, httpURL), while JavaScript and Python conventions typically lowercase them in camelCase (userId, httpUrl) except at the start of PascalCase.

Numbers in Identifiers

Numbers embedded in identifiers create ambiguity. Is "base64Encode" two words ("base64" and "Encode") or three ("base", "64", "Encode")? Most converters treat digit sequences as part of the preceding word unless separated by an explicit delimiter.

Single-Character Words

Single letters can be ambiguous in camelCase. Is "aButton" one word or two? Context determines the answer, but automated converters must make assumptions. Most treat any uppercase letter after a lowercase letter as a word boundary.

Unicode and International Characters

Case conversion with Unicode characters introduces additional complexity. Not all scripts have uppercase/lowercase distinctions. Turkish has the dotted/dotless "i" problem where I.toLowerCase() should produce a dotless i in Turkish locale. German has the sharp s (eszett) that expands to "SS" in uppercase. Robust converters must handle locale-specific rules.

8. Best Practices

Following naming convention best practices improves code quality, reduces bugs, and makes collaboration smoother.

9. Using Our Free String Case Converter Tool

Our String Case Converter instantly converts text between all major naming conventions: camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case, Title Case, Sentence case, dot.case, and more.

Simply paste your identifier, variable name, or any text into the input field, and the tool shows the converted result in every supported convention simultaneously. It handles acronyms intelligently, supports batch conversion of multiple identifiers, and provides one-click copying for each result.

Whether you are migrating code between languages, designing API schemas, renaming database columns, or just need a quick conversion for a CSS class name, this tool handles the tedious work instantly.

Try the String Case Converter

Frequently Asked Questions

What is camelCase?

camelCase is a naming convention where the first word is lowercase and each subsequent word starts with an uppercase letter, with no separators. Examples: firstName, getUserData, isActive. It is the standard convention for variables and functions in JavaScript, Java, TypeScript, and many other languages.

What is the difference between camelCase and PascalCase?

camelCase starts with a lowercase letter (firstName, getUserData), while PascalCase starts with an uppercase letter (FirstName, GetUserData). PascalCase is typically used for class names and types, while camelCase is used for variables and functions.

When should I use snake_case vs camelCase?

Follow the convention of your programming language: Python, Ruby, and Rust use snake_case; JavaScript, Java, and TypeScript use camelCase. For APIs, follow the convention that best serves your consumers.

What is kebab-case used for?

kebab-case uses lowercase words separated by hyphens. It is used for CSS class names, URL slugs, HTML attributes, CLI flags, npm package names, and file names in web projects.

What is SCREAMING_SNAKE_CASE?

SCREAMING_SNAKE_CASE uses all uppercase letters with underscore separators. It is the universal standard for constants and environment variables across all programming languages.

How do you convert between naming conventions programmatically?

Split the string into words (by detecting separators or case transitions), normalize all words to lowercase, and rejoin using the target convention's rules. You can also use our free String Case Converter tool for instant conversion.