Naming conventions might seem like a trivial style preference, but they have real implications for code readability, tooling compatibility, and team collaboration. Mixing conventions in a codebase is one of the most common sources of subtle bugs and unnecessary friction.
Here's a definitive guide to every major case format and exactly where each one belongs.
The 9 Major Text Case Formats
UPPER CASE
All characters capitalized, spaces preserved.
Example: HELLO WORLD
Used for: Acronyms (NASA, API, URL), emphasis in writing, some constants in older languages (SQL keywords), warning messages.
lower case
All characters lowercase, spaces preserved.
Example: hello world
Used for: Email addresses, some code identifiers, informal writing. Rarely used as a standalone naming convention in code.
Title Case
First letter of each word capitalized.
Example: Hello World
Used for: Article titles, book titles, heading text, UI labels, blog post titles. Note: style guides differ on whether small words like "a", "the", "and" should be capitalized.
Sentence case
Only the first letter of the first word is capitalized.
Example: Hello world
Used for: Body text, email subjects, most UI copy, product descriptions. The default case for prose writing.
camelCase
No spaces. Each word after the first starts with a capital letter. First word is lowercase.
Example: helloWorld, getUserById, firstName
Used in: JavaScript/TypeScript variable names, Java method names, Swift, Kotlin, Dart. The dominant convention for variables and functions in most modern languages.
PascalCase (UpperCamelCase)
Like camelCase but the first word is also capitalized.
Example: HelloWorld, UserProfile, MyComponent
Used in: Class names in almost all OOP languages (Java, C#, TypeScript, Python), React component names, constructor functions, enum names.
snake_case
Words separated by underscores. All lowercase.
Example: hello_world, user_id, first_name
Used in: Python (PEP 8 standard for variables and functions), Ruby, database column names, JSON keys in some APIs, file names in many Unix systems.
kebab-case
Words separated by hyphens. All lowercase.
Example: hello-world, user-profile, my-component
Used in: CSS class names, HTML attributes, URL slugs, npm package names, file names in web projects, command-line flags.
CONSTANT_CASE (SCREAMING_SNAKE_CASE)
All uppercase with underscores between words.
Example: HELLO_WORLD, MAX_RETRY_COUNT, API_BASE_URL
Used in: Constants in JavaScript/TypeScript (const MAX_SIZE = 100), Python global constants, environment variable names (.env files), C/C++ #define macros.
Quick Reference by Language/Context
| Language/Context | Variables/Functions | Classes | Constants | Files |
|---|---|---|---|---|
| JavaScript/TS | camelCase | PascalCase | CONSTANT_CASE | kebab-case |
| Python | snake_case | PascalCase | CONSTANT_CASE | snake_case |
| Java | camelCase | PascalCase | CONSTANT_CASE | PascalCase |
| CSS | kebab-case | — | — | kebab-case |
| Databases | snake_case | — | — | snake_case |
| URLs/Slugs | kebab-case | — | — | — |
| React | camelCase (props) | PascalCase (components) | — | PascalCase |
A Worked Example: One Concept, Every Case
To make the differences concrete, here's the same three-word concept — a user's date of birth — expressed in each convention exactly as you'd write it in the wild:
| Case | Output | Where you'd type it |
|---|---|---|
| camelCase | userDateOfBirth |
JS/TS variable |
| PascalCase | UserDateOfBirth |
C# property, class name |
| snake_case | user_date_of_birth |
Python variable, DB column |
| kebab-case | user-date-of-birth |
CSS class, URL slug |
| CONSTANT_CASE | USER_DATE_OF_BIRTH |
env var, config constant |
| Title Case | User Date Of Birth |
form label, table header |
Notice the boundaries are identical in every version — the only thing that changes is the separator and the capitalization. That's exactly what a converter automates: it splits your input into words, then reassembles them under the rules of the target case.
The Tricky Edge Cases
Case conversion looks trivial until you hit real-world strings. These are the ones that trip up naive converters (and hand-rolled regex):
- Acronyms. Should
getHTTPResponsebecomeget_h_t_t_p_responseorget_http_response? Good converters treat consecutive capitals as a single unit, giving youget_http_response. - Numbers. Is
address2one word or two? Most tools keep the digit attached (address2→address_2is a common but debatable choice), so check the output when numbers matter. - Existing separators. Converting
first-nameto camelCase should yieldfirstName, notfirstname— the hyphen is a word boundary, not a character to delete blindly. - Leading/trailing junk. Stray spaces, double underscores, or a trailing period can leak into the output if the converter doesn't trim first.
If you're writing your own conversion in JavaScript, this handles the common snake-to-camel case cleanly:
const toCamel = (s) =>
s.toLowerCase().replace(/[-_ ]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))
toCamel("user_date_of_birth") // → "userDateOfBirth"
toCamel("user-date-of-birth") // → "userDateOfBirth"
Common Mistakes
Mixing conventions in one layer. The classic offender is a JSON API returning first_name and dateOfBirth in the same response. Pick one and stick to it; if your backend is Python (snake_case) and your frontend is JS (camelCase), convert at the boundary, not randomly per field.
Using underscores in URL slugs. Google treats hyphens as word separators but underscores as connectors, so my_blog_post may be read as a single token for ranking. Always use kebab-case for slugs.
Renaming with find-and-replace across a whole project. A blind replace of userId catches userIdentifier too. Use your editor's "rename symbol" (which is case- and boundary-aware) or a dedicated converter on the specific strings.
Converting Between Cases Instantly
Manually converting between cases is tedious, especially when renaming variables across a file or reformatting data from one system to another. Use our free Text Case Converter tool to convert any text between all 10 formats instantly.
A practical tip: when you're migrating a spreadsheet column of messy headers ("First Name", "e-mail address", "Phone_Number") into clean database column names, paste the whole column into a case converter set to snake_case in one pass rather than fixing each cell by hand. It normalizes the spacing, casing, and separators simultaneously — turning a 20-minute cleanup into a 20-second one. If you also need to check length limits, our Word Counter is handy for spotting headers that are too long.
Why Consistency Matters
Tooling: Code formatters, linters, and IDE features often depend on naming conventions. ESLint's camelcase rule, Python's pylint, and many others enforce conventions automatically.
Readability: Your brain learns to parse code faster when conventions are consistent. getUserById vs get_user_by_id vs GetUserById are all readable, but mixing them in the same file creates friction.
Interoperability: APIs, databases, and frontend frameworks often have incompatible conventions. Being able to quickly convert (e.g., database snake_case to API camelCase) is a practical daily skill.
SEO: URL slugs should always be kebab-case. Google treats hyphens as word separators but underscores as character connectors — text-case-converter is better for SEO than text_case_converter.
Frequently Asked Questions
What's the difference between camelCase and PascalCase?
They differ by exactly one letter — the very first one. camelCase lowercases the first word (userProfile), while PascalCase capitalizes it (UserProfile). The convention across most languages is camelCase for variables and functions, PascalCase for classes, types, and React components. That single-letter difference is meaningful to tooling: many linters and even the language itself (in the case of exported Go identifiers or React's component detection) rely on it.
Should I use snake_case or camelCase for my JSON API keys?
There's no universal rule, but consistency within your API matters more than the choice itself. camelCase is common when the API primarily serves JavaScript frontends (it maps directly to JS conventions), while snake_case is common in Python-, Ruby-, or Rails-based APIs. Whatever you pick, document it and enforce it — the worst option is a mix. Many teams convert automatically at the serialization layer so backend and frontend can each use their native convention.
Why do URLs use hyphens instead of underscores?
Because search engines and readers parse them differently. Google historically treats a hyphen as a word separator (so text-case-converter reads as three words) but an underscore as a character that joins words into one token. Hyphens are also easier to read and don't get hidden by the underline styling links often carry. For any public-facing URL slug, kebab-case is the safe default.
Is there a fast way to convert a whole column of text at once?
Yes — paste the entire block into a case converter rather than editing cell by cell. A good converter normalizes inconsistent spacing, capitalization, and separators in a single operation, which is exactly what you want when cleaning spreadsheet headers or a list of names before importing them into a database.
Conclusion
Naming conventions are a small decision you make hundreds of times a day, and consistency is what turns them from a chore into a benefit — predictable code, clean URLs, and painless data transfers. Learn where each case belongs, and let a tool handle the mechanical conversion.
Next step: open the Text Case Converter and try converting a variable name across all formats to see the rules in action.
