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.
Converts as you type. Nothing leaves your browser.
- camelCase
- PascalCase
- snake_case
- kebab-case
- CONSTANT_CASE
- Title Case
- Sentence case
- UPPER CASE
- lower case
- aLtErNaTiNg
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
| Case | hello world becomes | XMLHttpRequest becomes |
|---|---|---|
| camelCase | helloWorld | xmlHttpRequest |
| PascalCase | HelloWorld | XmlHttpRequest |
| snake_case | hello_world | xml_http_request |
| kebab-case | hello-world | xml-http-request |
| CONSTANT_CASE | HELLO_WORLD | XML_HTTP_REQUEST |
| Title Case | Hello World | XMLHttpRequest |
| Sentence case | Hello world | XMLHttpRequest |
| UPPER CASE | HELLO WORLD | XMLHTTPREQUEST |
| lower case | hello world | xmlhttprequest |
| aLtErNaTiNg | hElLo WoRlD | xMlHtTpReQuEsT |
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.
| Where | Variables and functions | Types and classes | Constants |
|---|---|---|---|
| JavaScript and TypeScript | camelCase | PascalCase | CONSTANT_CASE |
| Python (PEP 8) | snake_case | PascalCase | CONSTANT_CASE |
| Ruby | snake_case | PascalCase | CONSTANT_CASE |
| Rust | snake_case | PascalCase | CONSTANT_CASE |
| Go | camelCase, or PascalCase to export | PascalCase to export | camelCase or PascalCase |
| C# | camelCase locals, PascalCase methods | PascalCase | PascalCase |
| Java | camelCase | PascalCase | CONSTANT_CASE |
Outside a language's own names:
| Where | Usual case | Example |
|---|---|---|
| CSS classes and custom properties | kebab-case | --card-border-width |
| URLs and file names on the web | kebab-case | /resources/tools/case-converter |
| SQL tables and columns | snake_case | created_at |
| Environment variables | CONSTANT_CASE | DATABASE_URL |
| JSON keys | camelCase or snake_case, matching the API | userId, user_id |
| Headings and titles | Title Case or Sentence case, matching the style guide | How 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:
- Anything that is not a letter or a digit separates words: spaces,
_,-,.,/and the rest. - An apostrophe inside a word is dropped, so
don't stopisdontStopand notdonTStop. - A capital after a lower-case letter starts a word:
userNameisuserandName. - In a run of capitals, the last one starts a word if a lower-case letter
follows it:
XMLHttpisXMLandHttp. - A capital after a digit starts a word, unless the word so far is only
digits:
base64Encodeisbase64andEncode, but2FAstays whole. - Digits stay on the word before them:
userID2isuserandID2.
| Input | Words | snake_case |
|---|---|---|
userID2 | user, ID2 | user_id2 |
parseHTMLString | parse, HTML, String | parse_html_string |
base64Encode | base64, Encode | base64_encode |
HTML5Parser | HTML5, Parser | html5_parser |
SOME_CONSTANT | SOME, CONSTANT | some_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-case | Words |
|---|---|
| Articles | a, an, the |
| Short conjunctions | and, but, or, nor, for, so, yet |
| Short prepositions | as, 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.