All caps to sentence case
Choose sentence case. Every letter is lowered, then the first letter of each sentence is put back into capitals, and the pronoun I keeps its capital wherever it appears. Sentence boundaries come from the browser's own Unicode segmenter, with a short list of abbreviations that do not end a sentence, so a full stop after Dr or e.g. does not produce a stray capital.
Line by line
| 1 | WE HAVE MOVED THE MEETING TO THE MORNING. I HOPE THAT WORKS. LET ME KNOW IF IT DOESN'T. | We have moved the meeting to the morning. I hope that works. Let me know if it doesn't. |
On a line that is entirely in capitals the acronym option is ignored, because nothing distinguishes USA from every other word on that line.
Proper nouns cannot be recovered. Nothing in SEE YOU IN PARIS says that Paris is a city, so it comes back as paris and has to be fixed by hand.
The pronoun I is the one exception that is put back automatically, along with I'm, I've, I'll and I'd, because it is unambiguous in a way that a name is not.
How it works
How it is done
- Fold Windows and classic Mac line endings to a single newline, then split the text into lines. Every line is converted on its own, so a list of headings or column names goes through in one pass.
- Decide whether the line is shouting, meaning it has capitals in it and no lower case at all. On such a line the option to leave words already in capitals alone is ignored, because nothing there marks one word out as an acronym.
- For upper and lower case, apply the Unicode default case mappings to the whole line and stop. Those mappings are locale-independent, so the German ß becomes SS and the answer is the same on every machine.
- For title case, find the words - runs of letters and digits, which may have apostrophes inside them. A hyphen is not part of a word, so each element of a hyphenated compound is judged separately.
- Capitalise the first word, the last word and the first word after a colon. Lowercase any other word on the chosen style's list. Capitalise everything else. A word that directly follows a hyphen is exempt from the first-and-last rule.
- For sentence case, lower every word, put the pronoun I back, then capitalise the first letter of each sentence. Sentence boundaries come from the browser's Unicode segmenter, run over a case-blind copy of the line.
- Join a sentence to the one before it when that one ends in a single initial or in one of twenty listed abbreviations, so a full stop after "e.g." or "Mr." does not produce a stray capital.
- For camel, snake and kebab case, take the same words, drop their apostrophes, and split each one on a change of case - a lower-case letter or a digit followed by a capital, and a run of capitals followed by a lower-case letter.
- Join the parts. Lower case throughout for snake and kebab; for camel, a lowered first part with every later part capitalised.
What it assumes
- Each line is converted on its own. A title's first and last word are the first and last word of its line, a sentence never runs across a line break, and twenty column headers on twenty lines become twenty identifiers rather than one long one.
- Title case is a word list, not a grammar. Chicago lowercases prepositions by looking them up, so a preposition used adverbially is lowered where Chicago would capitalise it - "Look up the Answer" rather than "Look Up the Answer". Getting that right needs a part-of-speech tagger, which is a far larger and far less predictable thing than a list.
- The first and last word of a line are always capitalised, along with the first word after a colon. A word directly following a hyphen is exempt from that rule, which is what produces "Run-in with the Law" rather than "Run-In with the Law".
- Leaving words already in capitals alone is ignored on a line that is entirely in capitals. An acronym is a word in capitals among words that are not, and a shouted line offers no such contrast, so honouring the option there would convert a caps-lock accident into itself.
- Sentence case cannot restore a proper noun. Nothing in "we met in paris" says that Paris is a city, so it comes back lower case. The pronoun I is the single exception, because it is unambiguous in a way a name is not.
- Title and sentence case lower the rest of every word, so a deliberately mixed-case word is flattened - "parseHTMLDoc" becomes "Parsehtmldoc". Camel, snake and kebab case are the conversions that understand an existing identifier.
- Acronyms are folded in camel, snake and kebab case whatever the option says. "Customer ID" becomes customer_id, because a snake_case name carrying capitals is neither snake_case nor easier to read.
- Upper and lower case use the Unicode default mappings with no locale attached. The German ß becomes SS, which is correct, and does not come back as ß, which means the change is not reversible. A Turkish dotless i is cased by the default rules rather than the Turkish ones.
- A word beginning with a digit is left as it is, so "1st" stays "1st" and "3d" stays "3d" rather than becoming "1St" and "3D".
- Characters are counted as grapheme clusters. An accented letter written as two code points, or an emoji with a skin-tone modifier written as four, counts as one.
Common questions
Will it fix names and places that were typed in capitals?
No, and nothing can do it reliably. `JOHN` and `MARCH` are recoverable from a dictionary; `SMITH`, `READING` and `MAY` are ordinary words as well as names, so a tool that guessed would be wrong in ways you would have to check anyway. Everything is lowered and only sentence starts are capitalised, which leaves what needs fixing visible.
Why is the word after a full stop capitalised but not the one after a colon?
Because a colon does not end a sentence in English, and neither does a semicolon. Only a full stop, a question mark and an exclamation mark start a new one here. Some American house styles do capitalise after a colon when a complete clause follows; that is one to fix by hand.
Sources
The full method, worked example and every assumption behind this figure are on Case Converter.