Skip to main content
Developer Tools June 26, 2026 · 5 min read

How to Convert Text Case: camelCase, snake_case, Title Case, and More

Every programming language, framework, and style guide has its own naming convention. Understanding which case format to use — and how to convert between them — is a small but daily friction point for developers. This guide covers all the common formats and when to use each.

The Common Text Case Formats

camelCase

firstWordLower

JavaScript variables, functions, JSON keys. First word lowercase, subsequent words capitalised, no separators.

PascalCase (UpperCamelCase)

FirstWordUpper

JavaScript/TypeScript class names, React components, C# types. Every word starts with a capital letter.

snake_case

words_with_underscores

Python variables and functions, database column names, Ruby. All lowercase, words separated by underscores.

SCREAMING_SNAKE_CASE

UPPER_WITH_UNDERSCORES

Constants in Python, JavaScript, C. All uppercase, words separated by underscores.

kebab-case

words-with-hyphens

CSS class names, HTML attributes, URL slugs, file names. All lowercase, words separated by hyphens.

Title Case

Every Major Word Capitalised

Article titles, headings, book titles. Articles and prepositions (the, a, of, in) are usually lowercase.

UPPER CASE

ALL CAPS

Acronyms, abbreviations, emphasis. Use sparingly.

lower case

all lowercase

URL paths, some config values, Python module names.

Quick Reference: Which Case by Language

Language / Context Variables Classes Constants
JavaScript / TypeScript camelCase PascalCase SCREAMING_SNAKE
Python snake_case PascalCase SCREAMING_SNAKE
Go camelCase PascalCase camelCase
Java / Kotlin camelCase PascalCase SCREAMING_SNAKE
Ruby snake_case PascalCase SCREAMING_SNAKE
CSS / HTML kebab-case
SQL snake_case UPPER_CASE
URL slugs kebab-case

How to Convert Between Cases in Code

JavaScript

// snake_case to camelCase
const toCamel = s => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
toCamel('user_first_name'); // → 'userFirstName'

// camelCase to snake_case
const toSnake = s => s.replace(/[A-Z]/g, c => '_' + c.toLowerCase());
toSnake('userFirstName'); // → 'user_first_name'

// to kebab-case
const toKebab = s => s.replace(/[A-Z]/g, c => '-' + c.toLowerCase())
                       .replace(/_/g, '-').toLowerCase();
toKebab('userFirstName'); // → 'user-first-name'

Python

import re

def to_snake(name):
    s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()

def to_camel(name):
    parts = name.split('_')
    return parts[0] + ''.join(p.capitalize() for p in parts[1:])

to_snake('userFirstName')   # → 'user_first_name'
to_camel('user_first_name') # → 'userFirstName'

Common Conversion Mistakes

Acronyms in camelCase

Should "ID" become "id" or "Id"? Convention varies: userId vs. userID. Pick one and stick to it. TypeScript tends to use userId; older Java APIs used userID.

Numbers in identifiers

user2FA or user2Fa? The convention is usually to treat numbers as word boundaries only if followed by a capital. Keep numbers attached to what they describe.

Multi-word acronyms

HTMLParser vs. HtmlParser — Go style says HtmlParser (treat acronym as word), while many other languages prefer HTMLParser. Follow your language's official style guide.

Title Case vs. Sentence case

Title Case capitalises major words. Sentence case only capitalises the first word. Many UI designers mistakenly apply Title Case to all UI strings — modern style guides (Google, Apple) prefer Sentence case for UI labels.

Convert Text Case Instantly

Use our Text Case Converter to paste any text and convert it to camelCase, PascalCase, snake_case, kebab-case, UPPER CASE, lower case, or Title Case in one click. No installation needed — runs entirely in your browser.

Convert text case instantly — free