The same name can be written many ways: userAccountId, user_account_id, user-account-id, UserAccountId. Each style has a name, and each is the default in certain places. Using the right one makes code and URLs consistent and easier to read. This guide covers the common styles and where they are used.
When you need to switch text from one style to another, the QuickToolsBox Case Converter does it in your browser.
The common styles
| Style | Example | Notes | |---|---|---| | lowercase | user account id | Everything in small letters | | UPPERCASE | USER ACCOUNT ID | Everything in capitals | | camelCase | userAccountId | First word lowercase, later words start with a capital, no separators | | PascalCase | UserAccountId | Every word starts with a capital, no separators | | snake_case | user_account_id | Lowercase words joined with underscores | | SCREAMING_SNAKE_CASE | USER_ACCOUNT_ID | Uppercase words joined with underscores | | kebab-case | user-account-id | Lowercase words joined with hyphens | | Title Case | User Account Id | Words capitalized, with spaces, used in headings | | Sentence case | User account id | Only the first word capitalized |
Where each style is used
Conventions come from each language, framework, or system, so the right choice depends on where the name will live.
- camelCase: variables and functions in JavaScript, TypeScript, Java, and Swift. JSON keys in many web APIs.
- PascalCase: class and type names in most languages, and component names in frameworks such as React.
- snake_case: variables and functions in Python (as recommended by PEP 8), Ruby, and Rust, and column names in many databases.
- SCREAMING_SNAKE_CASE: constants in many languages, and environment variables such as
DATABASE_URL. - kebab-case: CSS class names and properties, HTML attributes such as
data-user-id, file names in many projects, and URL slugs. - Title Case and Sentence case: headings, titles, and interface labels in writing.
If a project has a style guide, follow it. Consistency within a codebase matters more than which style you prefer.
Why kebab-case is not used for variable names
In most programming languages, a hyphen means subtraction. user-account-id would be read as three names being subtracted, not one name. That is why kebab-case appears in places where hyphens are safe, such as CSS, file names, and URLs, while languages use underscores or capital letters inside identifiers.
URLs and file names
For web addresses, lowercase words separated by hyphens are the usual choice. Google's guidance for URLs recommends hyphens to separate words rather than underscores, because it treats hyphens as word separators. A slug like compress-image-to-size is easier for people and search engines to read than compressImageToSize. Lowercase also avoids problems, because on many servers a path is case-sensitive and /About and /about can be different pages.
For file names, avoid spaces and unusual characters when files will be used in commands, websites, or shared between systems. Hyphens or underscores work everywhere.
Title Case is not one rule
Title Case sounds simple but has no single standard. Style guides such as AP, Chicago, and APA differ on which small words, like "and", "of", "in", and "to", stay lowercase and how long a preposition must be before it is capitalized. A converter that capitalizes every word is a good first pass, but check headings against the style you follow. Sentence case, with only the first word and proper nouns capitalized, is simpler and is now the default in many software interfaces.
Acronyms and numbers
Acronyms are where conventions disagree. In camelCase, should a user ID be userId or userID? Some style guides treat an acronym as a word (userId, parseHtml), and others keep it fully capitalized (userID, parseHTML). Pick one rule for your project and use it everywhere. Digits can also cause surprises: address2 and address_2 convert differently depending on the tool, so check results when a name contains numbers.
Converting between styles
Converting by hand is slow and error-prone, especially for long lists of names. A converter first splits the text into words, then joins them in the target style. Splitting works from spaces, hyphens, underscores, and capital-letter boundaries. This works well for ordinary names, but for words with acronyms or digits it can guess wrong, so read the output before you paste it into code.
Typical uses include:
- Turning database column names (
created_at) into JavaScript property names (createdAt). - Turning a page title into a URL slug (
My First Postbecomesmy-first-post). - Fixing text that was typed with caps lock on.
- Formatting a list of headings into Title Case or Sentence case.
Quick rules to remember
- Match the convention of the language or system you are writing for.
- Use lowercase with hyphens for URLs and most file names.
- Use PascalCase for types and classes, and camelCase or snake_case for variables according to the language.
- Pick one approach for acronyms and stick to it.
- Review converted output when names include acronyms or numbers.