/9 min read

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.

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:

CaseExampleWhen to Use
lowercasethe quick brown foxEmail addresses, URLs, CSS properties, most code text
UPPERCASETHE QUICK BROWN FOXAcronyms, emphasis, constants, short headings
Title CaseThe Quick Brown FoxHeadlines, book titles, formal headings
Sentence caseThe quick brown foxBody text, descriptions, UI labels
iNVERSE cASEtHE qUICK bROWN fOXCreative 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.profile

Each 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-converter

CONSTANT_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=abc123

Other Special Cases

Beyond the common formats, you may encounter these special case styles:

CaseExampleWhere Used
dot.caseuser.first.nameJava package names, property keys, configuration paths
path/caseuser/first/nameFile paths and route definitions
flatcaseuserfirstnamePackage names and compact identifiers
COBOL-CASEUSER-FIRST-NAMECOBOL and HTTP-style headers
aLtErNaTiNg CaSetHe QuIcK bRoWnMeme text and sarcasm notation

Naming Conventions by Language

Every major language has ecosystem conventions. Following them makes your code feel native to other developers.

LanguageVariables / FunctionsClasses / TypesConstants
JavaScript / TypeScriptcamelCasePascalCaseCONSTANT_CASE
Pythonsnake_casePascalCaseCONSTANT_CASE
JavacamelCasePascalCaseCONSTANT_CASE
C#camelCase private, PascalCase publicPascalCasePascalCase or CONSTANT_CASE
GocamelCase private, PascalCase exportedPascalCasePascalCase or CONSTANT_CASE
Rubysnake_casePascalCaseCONSTANT_CASE
Rustsnake_casePascalCaseCONSTANT_CASE
PHPcamelCase or snake_casePascalCaseCONSTANT_CASE
CSSkebab-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.

  1. Split by spaces, underscores, hyphens, punctuation, or uppercase letter boundaries.
  2. Normalize the words, usually by lowercasing them.
  3. 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_PROFILE

JavaScript

// 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 Converter

References

  1. Van Rossum, G., Warsaw, B., & Coghlan, A. PEP 8 - Style Guide for Python Code. https://peps.python.org/pep-0008/
  2. Google. Google JavaScript Style Guide. https://google.github.io/styleguide/jsguide.html
  3. Microsoft. C# Naming Conventions. https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names
  4. The Go Authors. Effective Go - Names. https://go.dev/doc/effective_go#names
  5. Rust Team. Rust API Guidelines - Naming. https://rust-lang.github.io/api-guidelines/naming.html
USTHJP