Which case for which job
Every style exists because some group of people agreed on it. Here is what each one is normally used for:
- UPPER CASE: acronyms, warning labels and short headings. Long passages are harder to read in capitals.
- lower case: tags, usernames, email addresses and search terms, anywhere capitalization should not matter.
- Title Case: headlines, and the titles of books, films and articles.
- Sentence case: ordinary writing, interface text, and headings in documentation styles that prefer it.
- camelCase and PascalCase: names in code. camelCase is common for variables and functions in JavaScript, Java and Swift, and for keys in many JSON APIs. PascalCase is common for classes and types.
- snake_case: Python and Ruby variables and functions, Rust, and SQL column names.
- kebab-case: URLs, CSS class names, HTML attributes and file names. Hyphens read well in an address but are not allowed in most variable names.
- CONSTANT_CASE: constants and environment variables.
- aLtErNaTiNg and iNVERSE cASE: mocking text in memes, and rescuing text typed with caps lock on.
How title case works, and why guides disagree
Title case capitalizes the important words of a title and leaves small ones in lower case. Where to draw the line is a matter of style, not grammar, so style guides disagree.
- AP and APA capitalize words of four letters or more and keep articles, short conjunctions and short prepositions in lower case. In 'A Walk Through the Park', Through gets a capital. (AP uses sentence case for its own news headlines, so its rule applies to the titles of works.)
- Chicago and MLA keep prepositions in lower case, whatever their length, along with articles and coordinating conjunctions. The same title becomes 'A Walk through the Park'.
- All of them capitalize the first and last word, and most capitalize the first word after a colon. Verbs such as is and be are capitalized, however short.
The converter applies those shared rules, but it cannot read your sentence. It does not know whether in belongs to a verb (Log In) or is a preposition (Life in the City), so it treats in and on as small words every time. Words that are often part of a verb or an adverb, such as up, off, out, down, inside, outside, near and past, are always capitalized, even though Chicago and MLA would lower them as prepositions. It treats to as a small word everywhere, and it cannot tell a proper noun from an ordinary word. Check a headline against your guide before you publish it.
Capitalize Each Word is a separate style that capitalizes every word, with no exceptions. It suits names and simple labels, not headlines.
Unicode, German ß and the Turkish dotted i
Case is not the same in every language, and a few letters break the idea that every capital has one small partner.
- German ß has no capital form in standard use, so converting to upper case writes SS. Converting back gives ss, so the round trip is lossy.
- Turkish and Azerbaijani have two i letters: dotted i with capital İ, and dotless ı with capital I. Standard rules turn I into i, which is wrong in Turkish. With the Turkish letter rules, 'istanbul' becomes 'İSTANBUL' and 'ISPARTA' becomes 'ısparta'.
- A dotted capital İ converted to lower case with standard rules becomes an i followed by a combining dot above, because that is what the Unicode rules say. It looks like i, but it is two characters.
- Greek final sigma is handled whenever a word is lowered, in lower case, title case and inverse case: ΟΔΟΣ becomes οδος, with the closing ς at the end.
- Scripts without case, such as Chinese, Japanese, Arabic and Hebrew, are left unchanged. Accents and other combining marks are kept.
How camelCase and snake_case split words
The word styles first split each line into words, then join them in the new style. Words are split at spaces, punctuation, underscores and hyphens, and where a lower case letter or digit meets a capital. So getUserName becomes get, User and Name. A run of capitals stays together until the capital that starts the next word: HTTPServer becomes HTTP and Server. A lower case s at the end of a run of capitals stays with it, so userIDs becomes user and IDs. Apostrophes are dropped, so it's becomes its.
Digits stay attached to the word before them, so version2Update becomes version2 and Update. In the output, acronyms are treated like ordinary words: 'XML HTTP request' becomes xmlHttpRequest, which several style guides, including Google's Java style guide, prefer. If your code base keeps acronyms in capitals, adjust those by hand. Each line is converted on its own, so a column of field names becomes a column of identifiers.