If you've ever looked at a variable named getUserById or a class named HttpRequestHandler, you've already seen camelCase in action. It's one of the most widely used naming conventions in software development — and understanding when and how to use it correctly will make your code more readable and consistent with the rest of your team's work.

What is camelCase?

CamelCase is a naming convention where multiple words are joined together without spaces, and each word (after the first) starts with a capital letter. The name comes from the visual resemblance to the humps of a camel:

firstName — two words, second word capitalized
totalPageCount — three words, second and third capitalized
getUserById — four words, subsequent words capitalized

lowerCamelCase vs UpperCamelCase (PascalCase)

There are two variants of camelCase, and the distinction matters:

  • lowerCamelCase — the first letter of the entire identifier is lowercase. Example: myVariable, calculateTax(), userProfile. This is what most people mean when they say "camelCase."
  • UpperCamelCase (also called PascalCase) — every word, including the first, starts with a capital letter. Example: MyVariable, CalculateTax(), UserProfile. This variant is used for class names and types in most languages.
Quick rule of thumb: Use lowerCamelCase for variables and functions. Use PascalCase (UpperCamelCase) for classes and types.

When Should You Use camelCase?

CamelCase is the standard convention in several major programming ecosystems. Here's where you'll find it most commonly:

JavaScript and TypeScript

JavaScript uses lowerCamelCase for variables, function names, and object properties. Classes use PascalCase. Constants are sometimes written in SCREAMING_SNAKE_CASE, though this isn't universal.

// Variables and functions → lowerCamelCase
const userName = 'Alice';
function fetchUserData(userId) { ... }

// Classes → PascalCase
class UserProfile { ... }

// Constants (optional convention)
const MAX_RETRY_COUNT = 3;

Java

Java enforces a strict convention: methods and variables use lowerCamelCase, while classes and interfaces use PascalCase. Packages are all lowercase without separators.

public class CustomerOrder {
  private int orderId;
  public String getOrderStatus() { ... }
}

C# and .NET

C# uses PascalCase for public members (methods, properties, classes) and lowerCamelCase for local variables and private fields. Microsoft's guidelines are explicit and well-documented.

JSON APIs

Many REST APIs return JSON with lowerCamelCase keys, particularly those built on Node.js or following Google's JSON Style Guide. If you're consuming or building an API, consistency with the existing naming is more important than following any single language's convention.

{
  "userId": 42,
  "firstName": "Alice",
  "lastLoginDate": "2025-04-10"
}

When Not to Use camelCase

CamelCase is not universal. Here are the contexts where other conventions are preferred:

  • Python — PEP 8 mandates snake_case for variables and functions. Using camelCase in Python code will technically work but will look wrong to any Python developer.
  • CSS class names — Use kebab-case (also called slug-case) for CSS selectors: .hero-section, .btn-primary.
  • URLs and file names — Use slug-case: my-blog-post.html, not myBlogPost.html.
  • Database column names — SQL conventionally uses snake_case: user_id, created_at.
  • Environment variables — Traditionally SCREAMING_SNAKE_CASE: DATABASE_URL, API_SECRET_KEY.

Handling Acronyms in camelCase

One of the trickiest parts of camelCase is dealing with acronyms. Should you write parseHTML or parseHtml? getURLParam or getUrlParam?

There's no universal answer, but the most widely adopted approach (used by Google, Microsoft, and many open-source projects) is to treat acronyms like regular words:

// Recommended: treat acronyms as words
parseHtml ✓   getUrlParam ✓   HttpRequest

// Avoid: all-caps acronyms mid-identifier
parseHTML ✗   getURLParam ✗   HTTPRequest

The exception: when an acronym appears at the start of a lowerCamelCase identifier, the entire acronym stays lowercase: htmlParser, urlBuilder.

Converting Text to camelCase

Need to quickly convert a phrase to camelCase? Use our free online converter above — just paste your text and click the camelCase button. It handles spaces, hyphens, underscores, and mixed casing automatically.

For example:

  • "get user by id" → getUserById
  • "total-page-count" → totalPageCount
  • "HTTP_REQUEST_HANDLER" → httpRequestHandler

Summary

CamelCase is a foundational naming convention in modern software development. Use lowerCamelCase for variables and functions in JavaScript, Java, and C#. Use PascalCase for classes and types. Treat acronyms as regular words for consistency. And when in doubt, follow the convention your codebase or style guide already uses — consistency always wins over any particular convention.