Skip to content
Home/Guides/camelCase Naming Convention — When and How to Use It
Guide·

camelCase Naming Convention — When and How to Use It

Naming conventions prevent arguments in code reviews and make codebases readable at a glance. camelCase is the most widely used convention in web development, and getting it right matters more than most developers realize.

What Is camelCase and When to Use It

camelCase joins multiple words into a single identifier by capitalizing the first letter of each word except the first one. The name comes from the uppercase letters in the middle of the word, which resemble the humps of a camel.

The pattern is simple: firstName, getUserData, isLoggedIn. The first word stays lowercase, every subsequent word gets its first letter capitalized, and no separators (underscores, hyphens, spaces) appear anywhere.

camelCase is the default naming convention for variables and functions in JavaScript, TypeScript, Java, and C#. If you write frontend code, you use camelCase constantly — for variable names, function names, object properties, and method names.

Step-by-Step Rules for camelCase

Rule 1: First word is entirely lowercase. The identifier always starts with a lowercase letter. userName is correct, UserName is PascalCase (a different convention).

Rule 2: Capitalize the first letter of each subsequent word. Every word after the first gets its initial letter uppercased: shoppingCartTotal, httpResponseCode, maxRetryCount.

Rule 3: No separators. No underscores, hyphens, or spaces. user_name is snake_case. user-name is kebab-case. userName is camelCase.

Rule 4: Handle acronyms consistently. This is where teams disagree most. There are two schools:

  • Treat acronyms as regular words: xmlHttpRequest, getApiUrl, parseJsonData
  • Keep acronyms fully capitalized: XMLHTTPRequest, getAPIURL, parseJSONData

The first approach is more readable and is recommended by most style guides, including Google's JavaScript style guide. When acronyms are fully capitalized, word boundaries become ambiguous — is XMLHTTP two acronyms or one?

Rule 5: Numbers are fine. Numbers can appear anywhere after the first character: vector2d, getTop10Results, layer3Protocol. Avoid starting with a number since most languages prohibit it anyway.

How FlipMyCase Helps

Manually converting multi-word phrases to camelCase gets tedious, especially when reformatting variable names from documentation, database columns, or API specs. The case converter at FlipMyCase handles this instantly.

Paste any text — whether it is a sentence, a snake_case identifier, or a kebab-case CSS class — and convert it to camelCase with one click. The tool handles acronym casing, strips special characters, and processes multiple lines at once. It is particularly useful when migrating between languages with different naming conventions, like converting Python's user_first_name to JavaScript's userFirstName.

Try it at flipmycase.com — no signup, no server processing, everything runs in your browser.

Tips, Variations, and Common Mistakes

lowerCamelCase vs UpperCamelCase. Technically, camelCase has two variants. lowerCamelCase (what most people mean by "camelCase") starts with a lowercase letter. UpperCamelCase starts with an uppercase letter and is more commonly called PascalCase. When someone says "camelCase" without qualification, they mean the lowercase variant.

dromedaryCase. Some developers call lowerCamelCase "dromedaryCase" since a dromedary camel has one hump while a Bactrian camel has two. This term is rarely used in practice.

Common mistake: inconsistent acronym handling. Mixing styles within a project — getAPIResponse in one file and getApiResponse in another — creates confusion. Pick one approach and enforce it with a linter.

Common mistake: using camelCase where another convention belongs. CSS classes use kebab-case (user-profile, not userProfile). Environment variables use CONSTANT_CASE (DATABASE_URL, not databaseUrl). Constants in most languages use SCREAMING_SNAKE_CASE. Using camelCase everywhere signals inexperience with language-specific conventions.

Common mistake: overly long names. calculateTotalPriceIncludingTaxAndShippingForAllItems is technically valid camelCase, but it is painful to read. If a name exceeds four words, the underlying concept probably needs restructuring.

Real-World Examples

Here is how common phrases convert to camelCase:

| Original | camelCase | |---|---| | user first name | userFirstName | | get HTTP response | getHttpResponse | | is logged in | isLoggedIn | | total item count | totalItemCount | | parse XML document | parseXmlDocument | | max retry count | maxRetryCount | | background color | backgroundColor |

JavaScript conventions: Variables and functions use camelCase. Classes use PascalCase. Constants use SCREAMING_SNAKE_CASE.

const maxRetries = 3;           // variable: camelCase
function getUserById(id) {}     // function: camelCase
class UserAccount {}            // class: PascalCase
const API_BASE_URL = '/api';    // constant: SCREAMING_SNAKE_CASE

Java conventions: Methods, variables, and parameters use camelCase. Classes use PascalCase. Constants use SCREAMING_SNAKE_CASE.

TypeScript conventions: Same as JavaScript, with interfaces and type aliases in PascalCase (UserProfile, ApiResponse).

Frequently Asked Questions

What is the difference between camelCase and PascalCase?

camelCase starts with a lowercase letter (firstName, getUserData), while PascalCase starts with an uppercase letter (FirstName, GetUserData). camelCase is used for variables and functions in most languages. PascalCase is reserved for class names, React components, TypeScript interfaces, and C# methods. The only structural difference is whether the first letter is capitalized.

Which programming languages use camelCase?

JavaScript, TypeScript, Java, and C# all use camelCase as the standard for variable and function names. Swift and Kotlin follow the same pattern. Python and Ruby prefer snake_case instead. CSS uses kebab-case for class names and properties. Most languages use camelCase for at least some identifiers, making it the most universally recognized naming convention in software development.

Should acronyms be fully capitalized in camelCase?

Most modern style guides recommend treating acronyms as regular words — getHttpResponse rather than getHTTPResponse. Fully capitalized acronyms make word boundaries harder to identify, especially when two acronyms appear next to each other. Google, Airbnb, and Microsoft style guides all favor the lowercase-acronym approach for better readability.

How do I convert text to camelCase automatically?

Use an online tool like FlipMyCase to paste any text and instantly convert it to camelCase. For programmatic conversion, JavaScript has no built-in method, but libraries like Lodash provide _.camelCase(). In your IDE, extensions like "Change Case" for VS Code can convert selected text between naming conventions with a keyboard shortcut.

When to Choose camelCase Over Other Conventions

The decision to use camelCase comes down to context. In JavaScript and TypeScript, camelCase is the only convention that feels native for variables and functions — using snake_case in a JavaScript file immediately signals "this came from an API or database." In Java, camelCase is enforced by convention so strongly that some linters treat violations as errors.

When working across language boundaries, camelCase often serves as the "common tongue." REST API response fields frequently use camelCase because JavaScript is the dominant consumer of web APIs. GraphQL schemas default to camelCase field names. JSON keys are typically camelCase in most API documentation.

However, camelCase is the wrong choice for CSS (use kebab-case), SQL columns (use snake_case), environment variables (use CONSTANT_CASE), and class names (use PascalCase). Using camelCase in these contexts does not cause errors, but it violates the expectations of everyone who maintains the code after you.

For configuration files, the convention depends on the format. YAML and JSON configs typically use camelCase or snake_case. TOML uses snake_case by convention. Properties files use dot.case. Match whatever the ecosystem expects.

camelCase in Popular Frameworks

React: Component props and state variables use camelCase: onClick, className, isVisible, setUserData. DOM attributes that differ from HTML use camelCase: tabIndex, htmlFor, autoFocus.

Angular: Services, variables, and functions use camelCase. Component selectors use kebab-case in templates but camelCase in TypeScript code.

Vue.js: Props can be defined in camelCase (myProp) and used in templates as kebab-case (my-prop). Vue handles the automatic conversion between the two conventions.

Express/Node.js: Route handlers, middleware functions, and utility modules all follow standard JavaScript camelCase conventions for function and variable names.

Conclusion

camelCase is foundational to writing clean JavaScript, TypeScript, and Java code. The rules are straightforward — lowercase first word, capitalize subsequent words, no separators — but consistency across a team requires discipline and tooling.

Convert any text to camelCase instantly at FlipMyCase, or explore the full suite of text case conversion tools for snake_case, PascalCase, kebab-case, and more.

Frequently Asked Questions

What is the difference between camelCase and PascalCase?

camelCase starts with a lowercase letter (firstName, getUserData), while PascalCase starts with an uppercase letter (FirstName, GetUserData). camelCase is used for variables and functions in most languages. PascalCase is reserved for class names, React components, TypeScript interfaces, and C# methods.

Which programming languages use camelCase?

JavaScript, TypeScript, Java, and C# all use camelCase as the standard for variable and function names. Swift and Kotlin follow the same pattern. Python and Ruby prefer snake_case instead. CSS uses kebab-case for class names and properties.

Should acronyms be fully capitalized in camelCase?

Most modern style guides recommend treating acronyms as regular words — getHttpResponse rather than getHTTPResponse. Fully capitalized acronyms make word boundaries harder to identify. Google, Airbnb, and Microsoft style guides all favor the lowercase-acronym approach for better readability.

How do I convert text to camelCase automatically?

Use an online tool like FlipMyCase to paste any text and instantly convert it to camelCase. For programmatic conversion, JavaScript has no built-in method, but libraries like Lodash provide _.camelCase(). In your IDE, extensions like "Change Case" for VS Code can convert selected text between naming conventions with a keyboard shortcut.

Free Text Tools