camelCase Converter: camelCase, PascalCase and Naming Rules

UPPERLOWERCASE.COM camelCase Converter camelCase and PascalCase, both ways before user first name after userFirstName

camelCase joins words with no spaces and capitalizes every word after the first: userFirstName, getElementById, maxRetryCount. The name comes from the humps. Capitalize the first word too and you get PascalCase: UserFirstName.

The converter below turns a phrase into camelCase or PascalCase, and turns an existing identifier back into readable words. Under it: which language expects which style, what to do with acronyms such as HTTP and ID, and the three-line formula that does the same job in Excel.

RESULT

More than code casing. The full upper lower case converter also does UPPERCASE, lowercase, Sentence case, Title Case, snake_case and kebab-case, with a live character count. Free, no sign-up.

camelCase, PascalCase and the rest of the family

Six naming styles cover almost all code written today. They differ only in the separator and in which letters are capitalized.

StyleSame three wordsAlso called
camelCaseuserFirstNamelower camel case, dromedary case
PascalCaseUserFirstNameupper camel case, capital camel case
snake_caseuser_first_nameunderscore case
SCREAMING_SNAKE_CASEUSER_FIRST_NAMEconstant case, macro case
kebab-caseuser-first-namedash case, spinal case, lisp case
dot.caseuser.first.nameproperty case

The only difference between camelCase and PascalCase is the first letter, and that single letter carries real meaning in most languages: it usually separates a value from a type. In Java, C#, TypeScript and Swift, userAccount is a variable and UserAccount is a class. Getting it backwards compiles fine and reads wrong to every other developer on the team.

Which language expects which case

Conventions are not personal preference. Each language has a published style guide, and linters enforce it.

LanguageVariablesFunctionsClassesConstants
JavaScriptcamelCasecamelCasePascalCaseSCREAMING_SNAKE
TypeScriptcamelCasecamelCasePascalCaseSCREAMING_SNAKE
JavacamelCasecamelCasePascalCaseSCREAMING_SNAKE
C#camelCasePascalCasePascalCasePascalCase
Pythonsnake_casesnake_casePascalCaseSCREAMING_SNAKE
Rubysnake_casesnake_casePascalCaseSCREAMING_SNAKE
GocamelCasePascalCase if exportedPascalCasePascalCase
SwiftcamelCasecamelCasePascalCasecamelCase
PHPcamelCasecamelCasePascalCaseSCREAMING_SNAKE
SQLsnake_casesnake_case
CSSkebab-casekebab-case

C# is the outlier worth remembering. It uses PascalCase for public methods and properties, where Java and JavaScript use camelCase. A developer moving between the two writes getName() in C# out of habit and every reviewer flags it. In Go, the case of the first letter is not a convention at all: it is the access modifier. A capital means exported, a lowercase letter means package private.

The acronym problem: getHTTPResponse or getHttpResponse?

This is the one camelCase argument that never fully ends. When a word inside an identifier is an acronym, do you keep it in capitals or treat it as an ordinary word?

Written asExampleWho recommends it
Acronym as a wordgetHttpResponse, parseXmlFile, userIdGoogle Java style, .NET guidelines for 3+ letters
Acronym in capitalsgetHTTPResponse, parseXMLFile, userIDOlder Java code, much of Apple’s Objective-C API
Two-letter acronymsIOStream, dbID.NET keeps two-letter acronyms capitalized

The practical argument for treating an acronym as a word is that it survives round trips. getHTTPResponse split back into words gives get H T T P Response unless the splitter has a special rule; getHttpResponse gives get http response every time. Two consecutive acronyms make it worse: parseXMLHTTPRequest has no readable boundary at all.

The converter above offers both. The recommended mode treats an acronym as a word; the strict mode keeps it in capitals. Pick one and let the linter enforce it, because the cost here is inconsistency rather than either choice being wrong. The same tension appears in ordinary prose, where the capitalization rules for acronyms are more settled.

How to convert to camelCase in code

LanguageApproach
JavaScriptSplit on spaces, lowercase the first word, capitalize the first letter of the rest, join with nothing
PythonUse str.split(), then parts[0].lower() + ''.join(p.capitalize() for p in parts[1:])
JavaApache Commons Text has CaseUtils.toCamelCase(text, false, ' ')
PHPlcfirst(str_replace(' ', '', ucwords($text)))
Lodash_.camelCase('user first name') returns userFirstName
Excel=LOWER(LEFT(SUBSTITUTE(PROPER(A1)," ",""),1)) & MID(SUBSTITUTE(PROPER(A1)," ",""),2,999)

The Excel formula is the one people ask for and rarely find. It works in three moves: PROPER capitalizes every word, SUBSTITUTE removes the spaces, and LOWER(LEFT(...,1)) puts the first letter back down. It inherits every limitation of PROPER, which is documented in our guide to the proper case converter and the Excel PROPER trap.

Where camelCase appears outside code

Three places, and one of them matters to a large audience.

  • Hashtags. #NationalPetDay is readable; #nationalpetday is a wall. This is not only aesthetics: screen readers pronounce a camel case hashtag word by word and a lowercase one as a single unintelligible string. Both Twitter and accessibility guidelines have recommended camel case hashtags for over a decade.
  • Brand names. iPhone, eBay, YouTube, PayPal, JavaScript. A case converter that lowercases these has damaged the text, which is why the converter on this site detects internal capitals and leaves them alone.
  • Wiki links and file names. The original WikiWord convention was camel case, and it survives in file names where spaces cause trouble.

Never camelCase a URL. Paths on a Linux server are case sensitive, so /userProfile and /userprofile are two different pages that can split your search signals. Use kebab-case for URLs: /user-profile. Google has been explicit that hyphens, not underscores or capitals, are the word separator it reads.

camelCase and readability

Removing the spaces costs something. Studies of code comprehension have generally found that snake_case is read slightly faster than camelCase by people who are new to a codebase, while experienced developers show little difference and often prefer camelCase because it is shorter and needs no shift key on every word.

The underlying reason is the same one that makes a paragraph of capitals hard to read: the eye uses word shape and word boundaries, and camelCase replaces a clear boundary (the space) with a subtler one (a height change). That trade-off is the same argument set out for ordinary prose in uppercase vs lowercase and the art of uppercase and lowercase writing.

IdentifierCharactersBoundary marker
user first name15Space, unambiguous
userFirstName13Capital letter
user_first_name15Underscore, visually explicit
user-first-name15Hyphen, invalid in most identifiers

Five camelCase mistakes

  • Mixing camelCase and snake_case in one codebase. The cost is not aesthetic. Every developer has to remember which convention a given module uses before they can guess a name, and guessing names correctly is most of what reading code is.
  • Capitalizing after a digit. address2Line and address2line both appear in the wild. Pick one; most style guides treat a digit as part of the preceding word, giving address2Line only if line is a new word.
  • Using PascalCase for a variable. In Java, C# and TypeScript this reads as a type name and will confuse every reviewer.
  • Converting a whole sentence. camelCase is for identifiers of two to four words. theQuickBrownFoxJumpsOverTheLazyDog is not a name, it is a sentence with the spaces removed.
  • Trusting a naive converter with acronyms. Most simple implementations turn HTTP response code into hTTPResponseCode. Test yours on an acronym before running it over a file.

Twelve case styles, one click. The upper lower case converter handles camelCase, PascalCase, snake_case, kebab-case, Title Case, Sentence case, UPPERCASE and lowercase, with acronym protection and a live count. Free, in your browser.

camelCase in APIs, JSON and databases

The hardest casing decisions are not inside one file, they are at the boundary between two systems that disagree.

LayerUsual conventionExample key
JSON REST APIcamelCasefirstName
GraphQLcamelCase for fields, PascalCase for typesfirstName, UserAccount
Relational databasesnake_casefirst_name
Environment variablesSCREAMING_SNAKE_CASEDATABASE_URL
HTTP headersTrain-CaseContent-Type
HTML data attributeskebab-case in markup, camelCase in JavaScriptdata-user-id becomes dataset.userId
CSS custom propertieskebab-case--brand-color

The last row is a small masterpiece of practical design: HTML writes data-user-id because attributes are case insensitive, and JavaScript reads it as dataset.userId because identifiers are not. The browser converts between the two for you, which is exactly what a mapping layer should do.

Where no such layer exists, decide once and convert at the edge. A Python service backed by a PostgreSQL database and serving a JavaScript front end will naturally hold three conventions at the same time: snake_case in the tables, snake_case in the Python code, and camelCase in the JSON it emits. That is not messy; it is each layer following its own standard, with one conversion function between them.

Do not convert case in two places. The classic bug is a serializer that camelizes keys plus a client that camelizes again. Fields such as user_id survive the first pass as userId and the second as userid, and the failure only shows up on the fields whose names happen to contain an underscore. Convert once, at a named boundary.

Naming rules that matter more than the case

Case is the part everyone argues about and the part that matters least. Four conventions do more for readability than any of them.

  • Booleans get a question prefix. isActive, hasPermission, canEdit, shouldRetry. A boolean named status or flag forces the reader to open the definition.
  • Collections are plural. users holds many, user holds one. Mixing them is how a loop ends up iterating over the letters of a string.
  • Avoid invented abbreviations. usrCnt saves four characters and costs every future reader a guess. Widely known short forms (id, url, max, min) are fine because they are already words.
  • Length should match scope. A loop counter can be i. A field on a public class needs a full phrase, because it will be read far from where it was written.

Renaming safely across a codebase

Converting an existing project from one convention to another is a mechanical job with two real hazards: string literals and the case-insensitive file systems on Windows and macOS.

  1. Use the editor refactor, not find and replace. Rename Symbol in VS Code and its equivalents in JetBrains editors understand scope. A plain text replace also rewrites comments, strings and unrelated identifiers that happen to share the name.
  2. Convert file names in two steps. git mv UserProfile.js temp.js then git mv temp.js userProfile.js. A direct rename that changes only capitalization is invisible to Git on a case-insensitive file system, and the change silently does not land.
  3. Search the string literals separately. Names used as JSON keys, database columns, CSS selectors or translation keys are not covered by a code refactor. Convert those with the tool above, in a list, and check them by eye.
  4. Add the linter rule in the same commit. Otherwise the old convention comes back the following week through a merge.

For a one-off conversion of a list of names, paste them into the converter above one per line, or into the text transformation tool for the simpler case changes. Larger batches in a spreadsheet are covered in upper and lower case in Excel, and the language-level methods in Python and Java.

A short history of the humps

The style is older than the languages that made it famous. Chemical formulas have used internal capitals for centuries, and early computing adopted them because identifiers could not contain spaces. The Smalltalk community popularized the modern form in the 1970s, C programmers largely stayed with underscores, and the split has survived every language generation since.

The name itself only arrived in the 1990s, in a Usenet thread, after earlier attempts including BiCapitalization and InterCaps failed to stick. camelCase won because it demonstrates itself. The broader story of how the two letter forms came to exist at all is in uppercase unveiled and the power of the upper lowercase converter.

Frequently asked questions

What is camelCase?

camelCase writes a multi-word identifier with no spaces, lowercase first word and a capital letter starting every word after it: userFirstName, getElementById, maxRetryCount. The capitals look like the humps of a camel.

What is the difference between camelCase and PascalCase?

Only the first letter. camelCase starts lowercase (userAccount); PascalCase starts uppercase (UserAccount). In most languages camelCase names values and PascalCase names types and classes.

How do I convert a sentence to camelCase?

Split it into words, lowercase the first word, capitalize the first letter of every following word, then join with no separator. The converter on this page does it for a whole list at once.

Which languages use camelCase?

JavaScript, TypeScript, Java, Swift, PHP, Kotlin and Go use camelCase for variables. Python, Ruby and SQL use snake_case instead. C# uses camelCase for local variables but PascalCase for public methods.

Should acronyms be capitalized in camelCase?

Google and Microsoft both recommend treating an acronym of three letters or more as an ordinary word: getHttpResponse rather than getHTTPResponse. It round-trips back to words reliably, which the capitalized form does not.

How do I convert camelCase back to words?

Insert a space before every capital letter and lowercase the result: userFirstName becomes user first name. The Back to words mode of the converter above does this, including for PascalCase input.

What is the Excel formula for camelCase?

Combine PROPER, SUBSTITUTE and LOWER: =LOWER(LEFT(SUBSTITUTE(PROPER(A1)," ",""),1)) & MID(SUBSTITUTE(PROPER(A1)," ",""),2,999). PROPER capitalizes each word, SUBSTITUTE removes the spaces, LOWER fixes the first letter.

Can I use camelCase in a URL?

You can, but you should not. Server paths are case sensitive on Linux, so two capitalizations become two separate pages. Use kebab-case in URLs: /user-profile.

The short version

camelCase joins words without spaces and capitalizes each one after the first; PascalCase capitalizes the first as well. Use camelCase for variables and functions in JavaScript, Java, Swift and PHP, PascalCase for classes everywhere and for public methods in C#, and snake_case in Python, Ruby and SQL. Treat acronyms of three letters or more as ordinary words so the name converts back cleanly, never put camelCase in a URL, and let a linter enforce whichever convention your codebase already uses.

Next Post Previous Post