filetity

Sentence case is where text tools destroy your acronyms

Sentence case has an obvious implementation. Lowercase the whole string, then capitalise the first letter of each sentence. It is two lines, it passes every example anyone writes for it, and it turns The NASA API returns JSON into The nasa api returns json.

Paste a paragraph of real writing into most online case converters and watch what happens to the proper nouns and the initialisms. The tool did exactly what it was asked. The ask was wrong.

The rule that works

A word written entirely in capitals, two letters or more, is left exactly as it is. That single condition saves NASA, API, JSON, PDF, HTTP and every other initialism, and it costs nothing, because a word in full capitals in the middle of a sentence is an acronym far more often than it is anything else.

Two more small ones earn their place. A standalone I stays capital, and so does the I in I'm. And a lone capital before a full stop, as in U.S., is an initial rather than the end of a sentence.

Then somebody pastes a shouted headline

Here is the input that breaks it, and it is the single most common thing anyone pastes into a case converter:

MERGE PDF FILES ONLINE FREE

Every word is entirely in capitals and two letters or more, so the acronym rule protects all of them, and sentence case returns the string untouched. The feature has eaten the function.

The fix is one line and it looks back at the whole input rather than at the word: if the text contains no lowercase letter anywhere, acronym preservation is off. Somebody typing in full capitals is not writing acronyms, they are shouting, and shouting is the exact case the converter exists to undo.

InputSentence case
the NASA API returns JSON.The NASA API returns JSON.
MERGE PDF FILES ONLINEMerge pdf files online

The second row loses the PDF, and that is the right trade. There is no information in an all-capitals string saying which words were acronyms, so any tool claiming otherwise is guessing. Returning the shout unchanged is worse than lowercasing one initialism.

While we are here: title case is not capitalising every word

The neighbouring mistake. Capitalising every word gives you Gone With The Wind, which is Start Case. Title case keeps articles, coordinating conjunctions and short prepositions lowercase unless they open or close the title, so it is Gone With the Wind.

The guides disagree about the details and it is worth saying which one you followed rather than pretending there is one answer. AP lowercases prepositions of three letters or fewer, so between is capitalised. Chicago lowercases all prepositions regardless of length, so it is not. Both are correct, under their own guide.

The tool this came out of

Ten cases, converting as you type, with your line breaks and punctuation preserved and nothing sent anywhere.

Open the case converter

filetity is built by Adarsh Mishra. If you have an input that breaks the rules above, that is genuinely useful to know and it will end up in the tests: support@filetity.com.