What is Text Case? A Developer's Guide to Naming Conventions
Whether you're naming a variable, writing a headline, or styling a CSS class, text case matters. From camelCase to snake_case, every programming language and writing system has its own conventions — and using the wrong one can break your code or confuse your readers.
Table of Contents
- What is Text Case?
- Basic Text Cases
- Programming Naming Conventions
- camelCase — The JavaScript Standard
- PascalCase — Classes and Components
- snake_case — The Python Way
- kebab-case — URLs and CSS
- CONSTANT_CASE — For Constants
- Other Special Cases
- Naming Conventions by Language
- Converting Between Cases
- Best Practices
What is Text Case?
Text case refers to the way letters are capitalized (or not) in a piece of text. In everyday writing, you're familiar with uppercase (HELLO), lowercase (hello), and title case (Hello World). But in the world of programming, text case has evolved far beyond that.
Developers have created specialized casing conventions — like camelCase, snake_case, and kebab-case — to solve a fundamental problem: most programming languages don't allow spaces in identifiers. You can't name a variable user first name, so developers needed conventions to join words together in a readable way.
These naming conventions have become deeply embedded in programming culture. Using the wrong case won't just look odd — in some languages and frameworks, it can cause actual errors or trigger lint warnings.
Basic Text Cases
Before diving into programming-specific conventions, let's cover the fundamental text cases used in everyday writing:
| Case | Example | When to Use |
|---|---|---|
| lowercase | the quick brown fox | Email addresses, URLs, CSS properties, most code |
| UPPERCASE | THE QUICK BROWN FOX | Acronyms, emphasis, constants, headings |
| Title Case | The Quick Brown Fox | Headlines, titles, headings, book names |
| Sentence case | The quick brown fox | Body text, descriptions, UI labels (Google style) |
| iNVERSE cASE | tHE qUICK bROWN fOX | Creative/meme text, rarely in professional contexts |
Title Case vs Sentence Case
The choice between title case and sentence case for UI text varies by design system. Apple's Human Interface Guidelines use Title Case for buttons and menu items. Google's Material Design prefers Sentence case. Pick one and be consistent throughout your product.
Programming Naming Conventions
Programming naming conventions solve a core problem: how do you represent multi-word names without spaces? Different languages and communities evolved different approaches, each with its own character and personality:
The phrase "get user profile" becomes:
camelCase: getUserProfile
PascalCase: GetUserProfile
snake_case: get_user_profile
kebab-case: get-user-profile
CONSTANT_CASE: GET_USER_PROFILE
dot.case: get.user.profileEach convention exists for a reason, and choosing the right one depends on your language, framework, and the type of identifier you're naming.
camelCase — The JavaScript Standard
camelCase (also called lower camelCase) starts with a lowercase letter, and each subsequent word starts with an uppercase letter. The "humps" in the middle look like a camel's back — hence the name.
// JavaScript / TypeScript — camelCase is king
const firstName = "Alice";
const lastName = "Smith";
const isLoggedIn = true;
function getUserProfile(userId) { ... }
function calculateTotalPrice(items) { ... }
function handleFormSubmit(event) { ... }
// React event handlers
onClick, onChange, onSubmit, onKeyDown
// JSON keys (by convention)
{ "firstName": "Alice", "lastName": "Smith" }camelCase is the dominant convention in JavaScript, TypeScript, Java (for methods and variables), Swift, and Kotlin. It's also the standard for JSON keys in most APIs.
Why "camel" Case?
The uppercase letters in the middle of the word create "humps" that resemble a camel's back: getUserProfile. The term was popularized in the 1990s and is widely used across the industry.
PascalCase — Classes and Components
PascalCase (also called upper camelCase or StudlyCaps) is similar to camelCase, but the first letter is also capitalized. It's named after the Pascal programming language, where it was a convention.
// Classes (almost every language)
class UserProfile { ... }
class ShoppingCart { ... }
class HttpRequestHandler { ... }
// React Components
function NavigationBar() { return <nav>...</nav>; }
function UserAvatar({ name }) { return <img alt={name} />; }
<SearchableToolGrid />
<ThemeToggle />
// TypeScript interfaces and types
interface UserSettings { ... }
type ApiResponse<T> = { data: T; error?: string };
// C# — PascalCase everywhere
public class OrderService {
public decimal CalculateTotal(List<OrderItem> items) { ... }
public string CustomerName { get; set; }
}PascalCase signals "this is a type, class, or constructor." In React, components must start with an uppercase letter — <myComponent /> would be treated as an HTML element, not a React component.
snake_case — The Python Way
snake_case uses underscores _to separate words, with all letters in lowercase. It gets its name because the underscores make the text look like it's slithering along the ground.
# Python — snake_case is the official style (PEP 8)
first_name = "Alice"
last_name = "Smith"
is_logged_in = True
def get_user_profile(user_id):
...
def calculate_total_price(items):
...
# Ruby — also snake_case
def send_welcome_email(user)
mail_service.deliver(user.email_address)
end
# Database columns
SELECT first_name, last_name, created_at
FROM user_accounts
WHERE is_active = true;snake_case is the standard in Python (enforced by PEP 8), Ruby, Rust, PHP (variables), and SQL. It's also the predominant convention for database table and column names.
Many developers find snake_case more readable than camelCase for long names: max_retry_attempts_per_request vs maxRetryAttemptsPerRequest. Studies on readability have found mixed results — familiarity matters as much as the format itself.
kebab-case — URLs and CSS
kebab-case (also called dash-case or lisp-case) uses hyphens - to separate words. The name comes from the visual similarity to food on a kebab skewer.
/* CSS class names — kebab-case is standard */
.navigation-bar { ... }
.user-profile-card { ... }
.btn-primary-large { ... }
/* CSS custom properties */
--primary-color: #3b82f6;
--font-size-base: 16px;
--border-radius-lg: 12px;
/* HTML data attributes */
<div data-user-id="123" data-is-active="true">
/* URLs and slugs */
/blog/what-is-text-case
/tools/text-case-converter
/api/user-profiles
/* File names (common in web projects) */
text-case-converter.tsx
user-profile.component.ts
api-client.jskebab-case is the standard for CSS classes, HTML attributes, URLs/slugs, and file names in web projects. It's also used in Lisp and Clojure for function names.
Why You Can't Use kebab-case for Variables
Most programming languages interpret the hyphen - as the subtraction operator. So user-name would be read as user minus name. That's why kebab-case is limited to contexts like CSS, HTML, and URLs where hyphens don't have arithmetic meaning.
CONSTANT_CASE — For Constants
CONSTANT_CASE (also called SCREAMING_SNAKE_CASE or UPPER_SNAKE_CASE) combines uppercase letters with underscores. It's universally used to indicate values that never change.
// JavaScript
const MAX_RETRY_COUNT = 3;
const API_BASE_URL = "https://api.example.com";
const HTTP_STATUS_OK = 200;
# Python
MAX_CONNECTIONS = 100
DEFAULT_TIMEOUT = 30
DATABASE_URL = "postgresql://localhost/mydb"
// Java
public static final int MAX_POOL_SIZE = 10;
public static final String API_KEY = "...";
// Environment variables (any language)
NODE_ENV=production
DATABASE_URL=postgres://...
NEXT_PUBLIC_API_KEY=abc123The "screaming" uppercase makes constants visually distinct from regular variables, immediately signaling "this value should not be changed." It's one of the few naming conventions that's nearly universal across all programming languages.
Other Special Cases
Beyond the big five, there are several less common but useful case formats:
| Case | Example | Where Used |
|---|---|---|
| dot.case | user.first.name | Java package names, property files, configuration keys |
| path/case | user/first/name | File paths, route definitions |
| flatcase | userfirstname | Package names (Java), some identifiers |
| COBOL-CASE | USER-FIRST-NAME | COBOL, HTTP headers (e.g., Content-Type) |
| aLtErNaTiNg CaSe | tHe QuIcK bRoWn | Meme text, sarcasm notation |
Naming Conventions by Language
Every major programming language has established conventions. Using the right case shows you know the ecosystem and makes your code feel natural to other developers:
| Language | Variables / Functions | Classes / Types | Constants |
|---|---|---|---|
| JavaScript / TypeScript | camelCase | PascalCase | CONSTANT_CASE |
| Python | snake_case | PascalCase | CONSTANT_CASE |
| Java | camelCase | PascalCase | CONSTANT_CASE |
| C# | camelCase (private) / PascalCase (public) | PascalCase | PascalCase or CONSTANT_CASE |
| Go | camelCase (private) / PascalCase (exported) | PascalCase | PascalCase or CONSTANT_CASE |
| Ruby | snake_case | PascalCase | CONSTANT_CASE |
| Rust | snake_case | PascalCase | CONSTANT_CASE |
| PHP | camelCase or snake_case | PascalCase | CONSTANT_CASE |
| CSS | kebab-case | — | --kebab-case (custom props) |
Notice a clear pattern: PascalCase for types/classes and CONSTANT_CASE for constants are nearly universal. The variation is mostly in how variables and functions are named.
Go's Unique Approach
Go is the only mainstream language where casing has semantic meaning. An identifier starting with an uppercase letter (PascalCase) is exported (public), while lowercase (camelCase) is unexported (private). So GetUser is public and getUser is private — enforced by the compiler, not just convention.
Converting Between Cases
Developers frequently need to convert between case formats — for example, when bridging between a Python API (snake_case) and a JavaScript frontend (camelCase), or when converting a title to a URL slug (kebab-case).
Conversion Algorithm
Most case conversions follow a two-step process:
- Split the input into individual words (by detecting boundaries — spaces, underscores, hyphens, or uppercase letters)
- Join the words back together using the target format's rules
Input: "getUserProfile"
Step 1 — Split by camelCase boundaries:
["get", "User", "Profile"] → ["get", "user", "profile"]
Step 2 — Join with target format:
snake_case: "get" + "_" + "user" + "_" + "profile" → get_user_profile
kebab-case: "get" + "-" + "user" + "-" + "profile" → get-user-profile
PascalCase: "Get" + "User" + "Profile" → GetUserProfile
CONSTANT_CASE: "GET" + "_" + "USER" + "_" + "PROFILE" → GET_USER_PROFILEJavaScript Examples
// camelCase → snake_case
"getUserProfile"
.replace(/([A-Z])/g, "_$1")
.toLowerCase()
.replace(/^_/, "");
// → "get_user_profile"
// snake_case → camelCase
"get_user_profile"
.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
// → "getUserProfile"
// Any case → kebab-case
"getUserProfile"
.replace(/([A-Z])/g, "-$1")
.toLowerCase()
.replace(/^-/, "");
// → "get-user-profile"
// String → Title Case
"the quick brown fox"
.replace(/\b\w/g, c => c.toUpperCase());
// → "The Quick Brown Fox"API Response Conversion
A common real-world scenario: converting snake_case API responses to camelCase for JavaScript:
// API response (Python/Ruby backend → snake_case)
{
"user_id": 42,
"first_name": "Alice",
"last_name": "Smith",
"is_active": true,
"created_at": "2026-01-15"
}
// Frontend JavaScript object (camelCase)
{
userId: 42,
firstName: "Alice",
lastName: "Smith",
isActive: true,
createdAt: "2026-01-15"
}Best Practices
- Follow your language's conventions — Don't use snake_case in JavaScript or camelCase in Python. Your code will look foreign and confuse other developers.
- Be consistent within a project — If your team chose camelCase for JSON keys, use it everywhere. Mixing conventions is worse than using a "wrong" one consistently.
- Use a linter — Tools like ESLint (JavaScript), Pylint (Python), and RuboCop (Ruby) can automatically enforce naming conventions and catch inconsistencies.
- Match the framework — React components must be PascalCase. CSS classes should be kebab-case. Database columns are typically snake_case. Don't fight the framework.
- Consider readability — For very long names, snake_case and kebab-case can be more readable than camelCase.
max_retry_attemptsvsmaxRetryAttempts— pick what's clearest in your context. - Handle abbreviations carefully — Is it
getURLParserorgetUrlParser? Different style guides differ. Google's JavaScript guide recommends treating abbreviations as words:getUrlParser,xmlHttpRequest. - Document your conventions — In a team project, write down which case to use where. Add it to your contributing guidelines or style guide.
Convert Text Case Instantly
Use our free Text Case Converter to transform text between camelCase, PascalCase, snake_case, kebab-case, Title Case, and 12 more formats — right in your browser with no data uploaded to any server.
Try Text Case Converter →References
- Van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 — Style Guide for Python Code. https://peps.python.org/pep-0008/
- Google. Google JavaScript Style Guide. https://google.github.io/styleguide/jsguide.html
- Microsoft. C# Naming Conventions. https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names
- The Go Authors. Effective Go — Names. https://go.dev/doc/effective_go#names
- Rust Team. Rust API Guidelines — Naming. https://rust-lang.github.io/api-guidelines/naming.html