Case Converter
Convert text into thirteen cases at once, from Title Case to snake_case, with words split correctly across acronyms, apostrophes and every script.
Overview
Case conversion rewrites the same words under a different convention. Prose has four: all lower, all upper,
a capital on every word, and a capital on every sentence. Code has more, because an identifier cannot contain
spaces, and every language settled on its own way of marking where one word ends and the next begins:
userName, user_name, user-name. The hard part of converting between them
is finding the words, and this tool does that once for all seven code conventions, so they cannot disagree.
Web interface
Type or paste into the field. All thirteen results update as you type, grouped into prose, code and two for
fun, and each is labelled in its own style. Copy copies one result, and is switched off for a
result with nothing in it. The line under the field counts characters, words and lines; words are counted by
the rules below, so getXMLHttpRequest is four. The dice in the field loads a random example,
Clear empties it.
Conversions
The prose cases change letters only, so punctuation, spacing and line breaks come through as they were.
For don't touch the café's espresso machine:
| Case | Result |
|---|---|
| lowercase | don't touch the café's espresso machine |
| UPPERCASE | DON'T TOUCH THE CAFÉ'S ESPRESSO MACHINE |
| Title Case | Don't Touch The Café's Espresso Machine |
| Sentence case | Don't touch the café's espresso machine |
Title Case capitalises every word and lower cases the rest of it, so iPhone becomes
Iphone and NASA becomes Nasa; it follows no style guide's list of small
words. Sentence case lower cases everything, I and names included, then capitalises the first
letter of each sentence: at the start, after ., !, ? or …
and a space, and on every new line, so a list gets a capital on each line. Opening quotes, brackets and the
Spanish ¿ and ¡ are stepped over to reach the letter.
The code cases split the text into words first and join them again. For
getXMLHttpRequest handler_v2:
| Case | Result |
|---|---|
| camelCase | getXmlHttpRequestHandlerV2 |
| PascalCase | GetXmlHttpRequestHandlerV2 |
| snake_case | get_xml_http_request_handler_v2 |
| kebab-case | get-xml-http-request-handler-v2 |
| CONSTANT_CASE | GET_XML_HTTP_REQUEST_HANDLER_V2 |
| dot.case | get.xml.http.request.handler.v2 |
| path/case | get/xml/http/request/handler/v2 |
An acronym becomes an ordinary word in camelCase and PascalCase, Xml rather than
XML, which is what makes the result convert back cleanly. The two for fun: l33t replaces
a b e g i l o s t z with 4 8 3 9 1 1 0 5 7 2 and leaves every other character
alone, and mOcKiNg alternates lower and upper case letter by letter, starting lower.
Where words are split
| Rule | Example |
|---|---|
| Anything that is not a letter or a digit separates words: spaces, hyphens, underscores, dots, slashes | user-name gives user_name |
| An apostrophe inside a word is dropped rather than splitting it, as lodash does | don't stop gives dont_stop |
| A capital after a lower case letter or a digit starts a word | getName gives get_name |
| An acronym stays whole, and its last capital starts the next word | XMLHttpRequest gives xml_http_request |
| Digits stay with the word they follow | HTML5 parser gives html5_parser |
| Each line is converted on its own | first name, last name on two lines give first_name, last_name |
Converting line by line is what makes a column of field names useful: paste
first name, last name and email address on three lines and every code
case comes back as three lines, firstName, lastName, emailAddress.
A separator is not remembered. path/to/file becomes pathToFile, and path/case
turns that back into path/to/file because it puts slashes in, not because it knew they were
there.
Other languages
Accented and non-Latin letters are letters. café stays whole, also when the accent arrives as a
character of its own after the e, as it does in text copied from macOS file names, and so does
Hindi नमस्ते, whose vowel signs are separate characters of that kind. Scripts without case, such as
Hindi, Chinese or Arabic, pass through the case changes as they are and are only split and joined.
Case follows Unicode's rules, which belong to no particular language:
- German
ßhas no single capital in those rules, so upper case turnsGrößeintoGRÖSSE, and lower case leavesßas it is. - Greek sigma is written
ςat the end of a word, soΟΔΟΣbecomesοδος. - Turkish is the exception that does not come out right: lower case turns
İintoifollowed by a combining dot above, and upper case turnsiintoIrather thanİ. Turkish rules would give the wrong result for every other language.
No API
There is no API for this tool. In a script, tr '[:lower:]' '[:upper:]' changes case on the
command line, and lodash's camelCase, snakeCase and kebabCase split
words in much the same way, except that lodash also removes accents, so café becomes
cafe.
Privacy
Nothing leaves the browser. The text is converted on the page as you type, nothing is stored or sent, and Copy writes to the clipboard only when you press it.