Developers & Technical · Guide · Developer Utilities
How to use text case conventions
Free guide to six text case styles — where camelCase, snake_case, PascalCase, and kebab-case belong, plus acronym and Title Case rules in your browser.
camelCase, PascalCase, snake_case, kebab-case, SCREAMING_CASE, Title Case — and they’re not interchangeable. Mixing them in a single codebase looks amateur; picking the wrong one for a URL or an environment variable breaks things silently. This guide covers each case convention, where it’s standard, the reasoning behind each choice, the edge cases (acronyms, numbers, leading underscores), and the style-guide rules that top-tier codebases follow.
Advertisement
The six cases you’ll use
camelCase: first word lowercase, subsequent words capitalized. userName, getUserById. JavaScript, Java, Kotlin, Swift variables and functions.
PascalCase (aka UpperCamelCase): every word capitalized. UserAccount, HttpRequest. Class names, types, React components, Go exported identifiers.
snake_case: lowercase words joined by underscores. user_name, get_user_by_id. Python, Ruby, Rust variables; PostgreSQL and most SQL database schemas.
SCREAMING_SNAKE_CASE: uppercase with underscores. MAX_RETRIES, API_KEY. Constants and environment variables in almost every language.
kebab-case (aka lisp-case or dash-case): lowercase with dashes. user-name, my-app- config. URLs, CSS class names, HTML attributes, CLI flags.
Title Case: each major word capitalized with spaces. The Quick Brown Fox. Article titles, headings, book names, UI labels.
Matching case to context
JavaScript / TypeScript:
camelCase for variables, functions, methods. PascalCase for classes, types, components, interfaces. SCREAMING_SNAKE_CASE for constants. kebab-case for file names (usually), though PascalCase for React component files is also common.
Python:
snake_case for variables, functions, modules. PascalCase for classes. SCREAMING_SNAKE_CASE for module-level constants. Leading underscore (_private) signals internal use; double leading underscore (__dunder) triggers name mangling in classes.
Go:
camelCase for unexported. PascalCase for exported (public). Visibility encoded in case — the language enforces it, so convention isn’t optional.
Ruby:
snake_case for variables and methods. PascalCase for classes and modules. SCREAMING_SNAKE_CASE for constants (Ruby enforces — start with a capital letter = constant).
Rust:
snake_case for variables and functions. PascalCase for types, traits, and enums. SCREAMING_SNAKE_CASE for constants and statics.
SQL (most dialects):
snake_case for tables, columns, indexes. Identifiers are case-insensitive but conventions matter: user_profiles, created_at.
CSS:
kebab-case for class names and custom properties. .nav-item, --text-color. HTML attributes same rule: data-user-id.
URLs:
kebab-case for paths and slugs. /blog/how-to-use-css-gradients, not /blog/how_to_use_css_gradients. Google confirmed dashes are preferred over underscores for word separators.
File names:
kebab-case is safest (cross-platform, no escaping, URL-safe). Exceptions: React component files (UserCard.jsx), Python modules (user_service.py).
Environment variables:
SCREAMING_SNAKE_CASE. DATABASE_URL, NODE_ENV. Universal across shells, CI systems, container orchestrators.
Acronyms — the hardest edge case
How do you write “HTTP server” in camelCase?
Standard (Google, Microsoft, Go): acronyms stay capitalized. HTTPServer, parseXMLFile. Treats the acronym as one unit.
Alternative (Java, older Microsoft): treat acronyms as words. HttpServer, parseXmlFile. Easier to parse visually; avoids ambiguity in subclasses (HttpServerFactory vs HTTPServerFactory).
In 2026 practice: the “treat acronyms as words” style (HttpServer) has mostly won, especially in new TypeScript and JavaScript codebases. Go still holds to all-caps acronyms as part of its style spec.
Pick one, document it, enforce it. Don’t mix HTTPClient and XmlParser in the same file.
Numbers in identifiers
Numbers attach to the adjacent word, typically without a separator: parseH264Stream, connectIPv6.
In snake_case: parse_h264_stream, connect_ipv6. Number stays adjacent; separator still present around words.
Leading digits are invalid in most languages.1stPlace → either firstPlace orplaceOne.
Title Case rules
For headlines and display text, Title Case isn’t just “capitalize every word.” Conventions exist:
APA style: capitalize first and last words; capitalize all major words (nouns, verbs, adjectives, adverbs); lowercase articles (a, an, the), short prepositions (of, in, for), and conjunctions (and, but, or). “How to Choose a Color Palette for a Website.”
Chicago style: similar but capitalizes prepositions 4+ letters (about, after, above).
Sentence case: only the first word capitalized, plus proper nouns. “How to choose a color palette for a website.” Popular on modern product UIs (Slack, Stripe, GitHub).
ALL CAPS: shouting. Useful for very short labels and notices; painful at paragraph length (reduces reading speed ~15-20%).
Converting between cases programmatically
When you need to convert programmatically, most languages have libraries or quick regex approaches:
camelCase → snake_case: replace capital letters with underscore + lowercase. someText.replace(/ ([A-Z])/g, "_$1").toLowerCase().
snake_case → camelCase: replace underscore + letter with capital letter. someText.replace(/_([a-z])/g, (_, c) => c.toUpperCase()).
Libraries: lodash has _.camelCase, _.snakeCase, _.kebabCase, _.startCase. Python has inflection. Ruby has these built into ActiveSupport.
Style guides worth reading
Google: language-specific style guides for JavaScript, Python, Java, Go, C++, Shell.
Airbnb JavaScript style guide: industry-standard for modern JS. Details case rules per identifier type.
PEP 8: the Python naming convention bible.
Effective Go: official Go case and naming conventions.
Common mistakes
Mixing conventions in a single codebase. A Python project with camelCase functions alongside snake_case ones is a code smell that broadcasts confusion.
Using snake_case in URLs. Dashes are SEO- safer. Underscores look like spaces were there and broke; search engines treat hyphens as word separators.
Casing database column names that match API field names. Database is snake_case; API is typically camelCase. Either transform at the boundary or accept the mismatch — don’t half-do one.
Over-capitalizing Title Case. “The How Of” looks wrong because Of shouldn’t be capitalized in most styles.
Inconsistent acronym handling. Pick “Http” or “HTTP” and stick with it across the whole project.
Run the numbers
Convert text between all common cases instantly with the case converter. Pair with the slug generator to produce URL-safe kebab-case from titles, and the diff checker to compare before/after when renaming identifiers across a file.
Use these while you read
Tools that pair with this guide
- Case ConverterConvert text to UPPERCASE, lowercase, Title Case, Sentence case, camelCase, snake_case, kebab-case. One click.Text & Writing Utilities
- URL Slug GeneratorGenerate clean, SEO‑ready URL slugs from any title. Free online tool — lowercase, dashes, no special characters. Instantly copy with one click, no registration needed.Text & Writing Utilities
- Character CounterCount characters with and without spaces. See limits for Twitter, SMS, meta descriptions, and more.Text & Writing Utilities
- Word CounterFree word counter. Paste text and see words, characters, sentences, and reading time instantly. Works offline after load.Text & Writing Utilities
Advertisement
Continue reading
- Developers & TechnicalGitHub Actions Without Being a DevOps ExpertMaster GitHub Actions for the 90% use case with this practical playbook. Build, test, and deploy instantly using free common templates and no-sign-up guides.
- Developers & TechnicalBest Practices for Building Developer ToolsLearn CI/CD, IDE, and documentation standards for paid dev tools instantly. Implement best practices for what companies actually buy online.
- Developers & TechnicalHow to Contribute to Open Source Developer ToolsFind beginner-friendly OSS projects and ship your first pull request with confidence. Free, instant playbook to avoid mistakes and scale contributions.
- Developers & TechnicalHow to Design CLI Tools Developers LoveFree guide to build CLI tools developers actually love: composability, sensible defaults, human errors, trust by default, predictability, fast feedback.
- Developers & TechnicalPassword Security Guide with Real Entropy ExamplesCalculate real password entropy with 2026 attacker speeds. Free guide to diceware passphrases, password managers, and 2FA based on actual attack vectors.
- Developers & TechnicalJSON Format Rules Every Developer Should KnowFree guide to strict JSON spec rules, JSON5 vs JSONC, top 10 parser errors, Schema validation, streaming huge files, and security: prototype pollution.