Text tool

Case Converter: camelCase, snake_case and Title Case

Convert text to camelCase, snake_case, kebab-case, Title Case, UPPER CASE and more in your browser. Handles acronyms and numbers, and uploads nothing.

Last updated

A case converter rewrites text in a different letter case without you retyping it: a heading into Title Case, a phrase into a camelCase variable name, a database column into snake_case. Type once and every case appears below, each with its own Copy button.

41 characters

Converts as you type. Nothing leaves your browser.

  • camelCase
    parseXmlHttpRequestResponseForUserId2
  • PascalCase
    ParseXmlHttpRequestResponseForUserId2
  • snake_case
    parse_xml_http_request_response_for_user_id2
  • kebab-case
    parse-xml-http-request-response-for-user-id2
  • CONSTANT_CASE
    PARSE_XML_HTTP_REQUEST_RESPONSE_FOR_USER_ID2
  • Title Case
    Parse XMLHttpRequest Response for userID2
  • Sentence case
    Parse XMLHttpRequest response for userID2
  • UPPER CASE
    PARSE XMLHTTPREQUEST RESPONSE FOR USERID2
  • lower case
    parse xmlhttprequest response for userid2
  • aLtErNaTiNg
    pArSe XmLhTtPrEqUeSt ReSpOnSe FoR uSeRiD2

Paste a sentence, a variable name or a list with one item per line. The code cases split words at spaces, punctuation and existing capitals, so XMLHttpRequest and user-id both come out right. The text cases keep your spacing and punctuation and change only the letters.

Every case at a glance

Casehello world becomesXMLHttpRequest becomes
camelCasehelloWorldxmlHttpRequest
PascalCaseHelloWorldXmlHttpRequest
snake_casehello_worldxml_http_request
kebab-casehello-worldxml-http-request
CONSTANT_CASEHELLO_WORLDXML_HTTP_REQUEST
Title CaseHello WorldXMLHttpRequest
Sentence caseHello worldXMLHttpRequest
UPPER CASEHELLO WORLDXMLHTTPREQUEST
lower casehello worldxmlhttprequest
aLtErNaTiNghElLo WoRlDxMlHtTpReQuEsT

The last column is the one that separates converters. Title Case and Sentence case leave XMLHttpRequest alone because it already has deliberate capitals, which is covered under Title Case rules.

Which case goes where

Each language has a house style, and code reads more easily when names follow it. These are the common conventions, not laws.

WhereVariables and functionsTypes and classesConstants
JavaScript and TypeScriptcamelCasePascalCaseCONSTANT_CASE
Python (PEP 8)snake_casePascalCaseCONSTANT_CASE
Rubysnake_casePascalCaseCONSTANT_CASE
Rustsnake_casePascalCaseCONSTANT_CASE
GocamelCase, or PascalCase to exportPascalCase to exportcamelCase or PascalCase
C#camelCase locals, PascalCase methodsPascalCasePascalCase
JavacamelCasePascalCaseCONSTANT_CASE

Outside a language's own names:

WhereUsual caseExample
CSS classes and custom propertieskebab-case--card-border-width
URLs and file names on the webkebab-case/resources/tools/case-converter
SQL tables and columnssnake_casecreated_at
Environment variablesCONSTANT_CASEDATABASE_URL
JSON keyscamelCase or snake_case, matching the APIuserId, user_id
Headings and titlesTitle Case or Sentence case, matching the style guideHow Cats Sleep

How words are split

The five code cases need to know where one word ends and the next begins. The rules, in order:

  1. Anything that is not a letter or a digit separates words: spaces, _, -, ., / and the rest.
  2. An apostrophe inside a word is dropped, so don't stop is dontStop and not donTStop.
  3. A capital after a lower-case letter starts a word: userName is user and Name.
  4. In a run of capitals, the last one starts a word if a lower-case letter follows it: XMLHttp is XML and Http.
  5. A capital after a digit starts a word, unless the word so far is only digits: base64Encode is base64 and Encode, but 2FA stays whole.
  6. Digits stay on the word before them: userID2 is user and ID2.
InputWordssnake_case
userID2user, ID2user_id2
parseHTMLStringparse, HTML, Stringparse_html_string
base64Encodebase64, Encodebase64_encode
HTML5ParserHTML5, Parserhtml5_parser
SOME_CONSTANTSOME, CONSTANTsome_constant

Rule 6 is a choice, and some converters make the other one. Splitting digits off turns utf8 into utf_8 and h1Title into h_1_title, which is rarely what anyone means.

Title Case rules

Title Case capitalises every word except the small ones, which stay lower-case in the middle of a title.

Kept lower-caseWords
Articlesa, an, the
Short conjunctionsand, but, or, nor, for, so, yet
Short prepositionsas, at, by, in, of, on, per, to, via, vs

A small word is capitalised when it is the first or last word, or when it starts a subtitle after a colon, so cats: a history of the nap becomes Cats: A History of the Nap. Each part of a hyphenated word counts as a word: state-of-the-art becomes State-of-the-Art.

Words with a capital past their first letter, such as NASA, iPhone or userID2, are left as typed, because lowering them is almost always a mistake. Text written entirely in capitals is the exception: there is no way to tell an acronym from shouting, so it is lowered first. Sentence case follows the same rule, and capitalises the first word of each sentence, the first word of each line and the word I.

Each line is converted on its own, in every case, so a pasted list stays a list.

Common questions

What is the difference between camelCase and PascalCase?

Only the first letter. camelCase starts lower-case and capitalises every word after it, as in userName. PascalCase capitalises every word including the first, as in UserName. Most languages that use both keep PascalCase for classes and types and camelCase for variables and functions, so the capital tells you what kind of thing a name is.

How does the converter handle acronyms like XMLHttpRequest or userID?

It splits them where a person would. A run of capitals is one word, and the last capital before a lower-case letter starts the next one, so XMLHttpRequest becomes XML, Http and Request, and xml_http_request in snake_case. A capital run at the end stays whole, so userID becomes user_id rather than user_i_d. Numbers stay on the word before them, so userID2 becomes user_id2.

Which words stay lower-case in Title Case?

Articles (a, an, the), short conjunctions (and, but, or, nor, for, so, yet) and prepositions of three letters or fewer (as, at, by, in, of, on, per, to, via, vs). They are capitalised anyway when they are the first or last word, or when they start a subtitle after a colon. Style guides disagree about longer prepositions such as with and from; this tool capitalises them, which AP and Chicago both accept.

Why did Title Case leave some of my capitals alone?

Words that already have a capital after their first letter, such as NASA, iPhone or XMLHttpRequest, are kept exactly as typed, because lowering them would be wrong more often than right. The exception is text written entirely in capitals, where there is no way to tell an acronym from shouting, so everything is lowered first. Sentence case follows the same rule.

Can I convert a list of names at once?

Yes. Every case works one line at a time, so paste a list with one name per line and each output keeps the same lines. That makes it quick to turn a column of labels into snake_case column names or a list of headings into Title Case.

Is anything I paste here sent to a server?

No. The conversion runs in your browser and the text box is not submitted anywhere. The site records that the tool was used, how many characters and lines went in and which case was copied, so we know which tools are worth building next. The text itself is never part of that.

See all tools

Want this explained by a cat?

The videos cover the same ground in sixty seconds. If there is a tool you want built next, ask.