What is Text Case? A Developer's Guide to Naming Conventions
Whether you are naming a variable, writing a headline, or styling a CSS class, text case matters. Different formats make text readable in different contexts, and in code they often signal meaning.
Table of Contents
What is Text Case?
Text case describes how letters are capitalized, separated, and joined. Everyday examples include uppercase, lowercase, title case, and sentence case.
In programming, text case also solves a practical problem: most identifiers cannot contain spaces. Developers use conventions such as camelCase, snake_case, and kebab-case to join words while keeping names readable.
These conventions are not just cosmetic. Frameworks, linters, databases, APIs, and programming languages often expect specific casing patterns.
Basic Text Cases
Before programming-specific formats, these are the basic cases used in writing and interfaces:
| Case | Example | When to Use |
|---|---|---|
| lowercase | the quick brown fox | Email addresses, URLs, CSS properties, most code text |
| UPPERCASE | THE QUICK BROWN FOX | Acronyms, emphasis, constants, short headings |
| Title Case | The Quick Brown Fox | Headlines, book titles, formal headings |
| Sentence case | The quick brown fox | Body text, descriptions, UI labels |
| iNVERSE cASE | tHE qUICK bROWN fOX | Creative text, meme text, rarely professional |
Title case vs sentence case
Design systems differ. Some use Title Case for buttons and menu items, while others prefer sentence case for a quieter interface. The important thing is consistency.
Programming Naming Conventions
Programming naming conventions answer one question: how do you represent multi-word names without spaces?
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. The right choice depends on the language, framework, and identifier type.
camelCase
camelCase starts with a lowercase letter and capitalizes each later word. It is the default style for variables and functions in JavaScript and many related ecosystems.
It is common in JavaScript, TypeScript, Java methods and variables, Swift, Kotlin, and many JSON APIs.
// JavaScript / TypeScript
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" }PascalCase
PascalCase capitalizes the first letter of every word. It is commonly used for classes, types, constructors, enums, and React components.
In React, component names must start with an uppercase letter. A lowercase JSX tag is treated like an HTML element, not a custom component.
// Classes
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 };snake_case
snake_case separates words with underscores and usually keeps letters lowercase. It is the official style for Python functions and variables under PEP 8.
It is also common in Ruby, Rust, SQL, database columns, many backend APIs, and configuration files.
# Python
first_name = "Alice"
last_name = "Smith"
is_logged_in = True
def get_user_profile(user_id):
...
def calculate_total_price(items):
...
# SQL columns
SELECT first_name, last_name, created_at
FROM user_accounts
WHERE is_active = true;kebab-case
kebab-case separates words with hyphens. It is widely used in URLs, CSS class names, HTML attributes, file names, and route paths.
Most programming languages cannot use kebab-case for variables because the hyphen is interpreted as a minus operator.
/* CSS */
.user-profile-card { ... }
.main-navigation { ... }
.is-loading { ... }
<!-- HTML data attributes -->
<button data-user-id="42" aria-label="Open menu">
// URL slugs
/blog/what-is-text-case
/tools/text-case-converterCONSTANT_CASE
CONSTANT_CASE, also called UPPER_SNAKE_CASE, uses uppercase letters with underscores. It visually signals a value that should not change.
This convention is nearly universal for constants and environment variables across languages.
// 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"
// Environment variables
NODE_ENV=production
DATABASE_URL=postgres://...
NEXT_PUBLIC_API_KEY=abc123Other Special Cases
Beyond the common formats, you may encounter these special case styles:
| Case | Example | Where Used |
|---|---|---|
| dot.case | user.first.name | Java package names, property keys, configuration paths |
| path/case | user/first/name | File paths and route definitions |
| flatcase | userfirstname | Package names and compact identifiers |
| COBOL-CASE | USER-FIRST-NAME | COBOL and HTTP-style headers |
| aLtErNaTiNg CaSe | tHe QuIcK bRoWn | Meme text and sarcasm notation |
Naming Conventions by Language
Every major language has ecosystem conventions. Following them makes your code feel native 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 properties |
Go's special rule
In Go, casing has semantic meaning. Names that start with an uppercase letter are exported from a package. Names that start lowercase are private to the package.
Converting Between Cases
Case conversion usually follows two steps: split the input into words, then join the words with the target format rules.
- Split by spaces, underscores, hyphens, punctuation, or uppercase letter boundaries.
- Normalize the words, usually by lowercasing them.
- Join them as camelCase, PascalCase, snake_case, kebab-case, or another target case.
Input: "getUserProfile"
Step 1: split into words
["get", "user", "profile"]
Step 2: join with the target format
snake_case: get_user_profile
kebab-case: get-user-profile
PascalCase: GetUserProfile
CONSTANT_CASE: GET_USER_PROFILEJavaScript
// camelCase to snake_case
"getUserProfile"
.replace(/([A-Z])/g, "_$1")
.toLowerCase()
.replace(/^_/, "");
// "get_user_profile"
// snake_case to camelCase
"get_user_profile"
.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
// "getUserProfile"
// Any simple case to kebab-case
"getUserProfile"
.replace(/([A-Z])/g, "-$1")
.toLowerCase()
.replace(/^-/, "");
// "get-user-profile"API
// API response from a Python/Ruby backend
{
"user_id": 42,
"first_name": "Alice",
"last_name": "Smith",
"is_active": true,
"created_at": "2026-01-15"
}
// Frontend JavaScript object
{
userId: 42,
firstName: "Alice",
lastName: "Smith",
isActive: true,
createdAt: "2026-01-15"
}Best Practices
- Follow the language convention so your code looks natural in its ecosystem.
- Be consistent within a project. Mixed naming conventions are harder to read than one imperfect convention used everywhere.
- Use a linter or formatter to enforce naming rules automatically.
- Match the framework: React components are PascalCase, CSS classes are often kebab-case, and database columns are commonly snake_case.
- Handle abbreviations deliberately. Decide whether to write getURLParser or getUrlParser and document the rule.
- Document team conventions in a style guide or contributing file.
Convert Text Case Instantly
Use our free Text Case Converter to transform text between camelCase, PascalCase, snake_case, kebab-case, Title Case, and more right in your browser.
Try Text Case ConverterReferences
- 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