Software Engineering & Architecture•Published October 2, 2026•14 min read

Text Case Formatting in Programming: camelCase, snake_case, PascalCase, and kebab-case

In computer programming, source code is read far more frequently than it is written. Because programming languages prohibit literal whitespace inside variable and function identifiers, developers rely on structured casing conventions to separate compound words into readable lexical tokens.

Choosing and enforcing the correct casing style is not merely an aesthetic preference. Modern software architectures span multi-lingual ecosystems: a single full-stack web application might communicate between a PostgreSQL database (snake_case), a Go backend microservice (PascalCase/camelCase), a REST JSON payload (camelCase), and a Tailwind CSS frontend (kebab-case).

In this engineering masterclass, we explore the origins and formal rules of each casing paradigm, map conventions across the world's most popular programming ecosystems, dissect complex word-boundary tokenization algorithms (including tricky acronym edge cases), and provide client-side conversion logic.

Advertisement
Responsive In-Article Ad Slot

The Taxonomy of Programming Casing Conventions

Programming casing styles are categorized by two dimensions: whether they utilize internal capitalization (capital humps) or explicit delimiter characters (underscores or hyphens):

Convention Name Canonical Example Delimiter / Rule Primary Ecosystems
camelCase fetchUserProfileData Initial lowercase; subsequent words capitalized. JavaScript, TypeScript, Java, Swift, Kotlin, JSON API keys.
PascalCase FetchUserProfileData Every word begins with an uppercase letter. C#, OOP Classes, React/Vue components, Go exported functions.
snake_case fetch_user_profile_data All lowercase words joined by underscores (_). Python (PEP 8), Rust, C, Ruby, SQL schemas.
SCREAMING_SNAKE MAX_RETRY_ATTEMPTS All uppercase words joined by underscores. Global constants, environment variables, Enum definitions.
kebab-case fetch-user-profile-data All lowercase words joined by hyphens (-). CSS selectors, HTML custom elements, URL slugs, Docker tags.
Train-Case / HTTP-Header Content-Security-Policy Capitalized words joined by hyphens. HTTP Headers, MIME headers, RFC 7230 protocol fields.

Ecosystem Standards & Canonical Style Guides

Every major language community has formalized naming standards into official style guides:

FULL-STACK DATA SERIALIZATION FLOW SQL Database user_auth_profile PostgreSQL / MySQL Case-insensitive schemas snake_case REST / JSON Payload {"userAuthProfile": {}} Serializer Middleware camelCase JSON standard camelCase DOM / CSS Selectors .user-auth-profile Tailwind / BEM CSS URL Route Parameters kebab-case
Figure 1: Architectural transformation across full-stack boundaries from SQL snake_case to JSON camelCase and DOM kebab-case.

1. JavaScript & TypeScript (Airbnb & Google Style Guides)

  • Variables, properties, functions: camelCase (e.g., const currentUser = getUser();).
  • Classes, interfaces, types, React components: PascalCase (e.g., interface UserAccount, <UserProfileCard />).
  • Constants: SCREAMING_SNAKE_CASE (e.g., const MAX_TIMEOUT_MS = 5000;).

2. Python (PEP 8)

  • Functions, methods, variables, modules: snake_case (e.g., def calculate_tax_total(), import auth_helpers).
  • Classes: PascalCase (e.g., class HttpRequestParser).
  • Protected & Private: Single leading underscore _internal_method() or double leading underscore for name mangling __private_attribute.

3. Go (Effective Go)

In Go, casing controls identifier visibility (package export). An identifier starting with an uppercase letter is exported (public), while an identifier starting with a lowercase letter is unexported (private package scope). Go explicitly rejects underscores in identifier names:

type ClientConfig struct { // Exported Struct (PascalCase)
    ServerURL   string      // Exported Field (PascalCase with acronym preserve)
    maxRetries  int         // Unexported Field (camelCase)
}

Convert Text & Code Cases Instantly

Transform identifiers, strings, and copy between camelCase, snake_case, PascalCase, kebab-case, and Title Case in your browser with zero latency.

Launch Text Case Converter →

The Acronym Edge Case: Parsing Complex Word Boundaries

The most common bug in automated case conversion algorithms occurs when encountering contiguous acronyms and numeric suffixes. Consider the string "parseXMLHTTPRequest2026Payload":

ACRONYM & BOUNDARY SPLITTING REGEX LOGIC "getHTML5DocumentURL" Rule A: Acronym followed by Word /([A-Z]+)([A-Z][a-z])/g Separates "HTMLDocument" → "HTML", "Document" Rule B: Lowercase followed by Upper/Num /([a-z0-9])([A-Z])/g Separates "getHTML5" → "get", "HTML5"
Figure 2: Two-stage lookahead regular expression mechanism for isolating acronym boundaries.

Naïve regex splitters (like /([A-Z])/g) erroneously split every capital letter, converting "parseXMLHTTPRequest" into "parse_x_m_l_h_t_t_p_request". A robust tokenizer uses positive lookahead/lookbehind patterns to keep acronym blocks unified:

Production JavaScript Case Conversion Engine

Here is an enterprise-grade JavaScript implementation that cleanly converts strings across all standard programming cases:

/**
 * High-Performance Client-Side Case Converter Engine
 */
export class CaseConverter {
  /**
   * Tokenizes arbitrary text into an array of lowercase semantic words
   * Correctly handles acronyms, numbers, hyphens, and underscores
   * @param {string} input 
   * @returns {string[]}
   */
  static tokenize(input) {
    if (!input) return [];

    return input
      .trim()
      // 1. Insert space between lowercase letter and uppercase letter (e.g. "fooBar" -> "foo Bar")
      .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
      // 2. Insert space between contiguous uppercase acronym and next capitalized word (e.g. "XMLHttp" -> "XML Http")
      .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
      // 3. Replace non-alphanumeric delimiters (underscores, dashes, dots) with whitespace
      .replace(/[^a-zA-Z0-9]+/g, ' ')
      .trim()
      .split(/\s+/)
      .filter(Boolean);
  }

  /** Convert to camelCase (e.g., 'fooBarBaz') */
  static toCamelCase(input) {
    const tokens = this.tokenize(input);
    if (tokens.length === 0) return '';
    return tokens[0].toLowerCase() + tokens.slice(1)
      .map(t => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase())
      .join('');
  }

  /** Convert to PascalCase (e.g., 'FooBarBaz') */
  static toPascalCase(input) {
    return this.tokenize(input)
      .map(t => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase())
      .join('');
  }

  /** Convert to snake_case (e.g., 'foo_bar_baz') */
  static toSnakeCase(input) {
    return this.tokenize(input)
      .map(t => t.toLowerCase())
      .join('_');
  }

  /** Convert to SCREAMING_SNAKE_CASE (e.g., 'FOO_BAR_BAZ') */
  static toScreamingSnakeCase(input) {
    return this.tokenize(input)
      .map(t => t.toUpperCase())
      .join('_');
  }

  /** Convert to kebab-case (e.g., 'foo-bar-baz') */
  static toKebabCase(input) {
    return this.tokenize(input)
      .map(t => t.toLowerCase())
      .join('-');
  }
}

Frequently Asked Questions

Standard modern style guides (such as Google TypeScript and Microsoft .NET) recommend treating acronyms longer than two characters as regular words (e.g., xmlHttpRequest or parseJsonString rather than XMLHTTPRequest). For two-letter acronyms, conventions vary: Go and .NET keep both uppercase in PascalCase (DB, IOStream), while JavaScript frameworks prefer db or ioStream.
In JavaScript, Python, C++, and most general-purpose programming languages, the hyphen character - is reserved as the arithmetic subtraction operator. An identifier like user-profile is parsed by compilers as user minus profile. In contrast, CSS selectors and URL query paths do not treat hyphens as operators, making kebab-case the ideal human-readable separator.
Enterprise backend architectures use serialization middleware, ORM mapping layers (like Prisma or TypeORM), or custom recursive key-transform utilities. When querying PostgreSQL/MySQL, columns like created_at and first_name are automatically transformed into createdAt and firstName before JSON payload transmission over HTTP.
SCREAMING_SNAKE_CASE (or CONSTANT_CASE) uses all-uppercase letters separated by underscores. It is the universal cross-language standard for compile-time constants, global immutable configurations, environment variables (e.g., DATABASE_URL), and enum keys.

Summary & Engineering Checklist

Consistent casing is one of the most effective ways to reduce cognitive load across engineering teams. By adopting ecosystem-native conventions within language boundaries and deploying programmatic transform layers at network and database serialization points, development teams ensure maximum readability and zero schema mismatches.

CS

Collabsource Editorial Team

Dedicated to programming language specifications, full-stack API architecture, developer tooling, and automated code quality linters.