Turn any text into every case at once, with the words found properly so XMLHttpRequest and user_id both come out right.
theQuickBrownFoxJumpsOverTheLazyDog
TheQuickBrownFoxJumpsOverTheLazyDog
the_quick_brown_fox_jumps_over_the_lazy_dog
THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG
the-quick-brown-fox-jumps-over-the-lazy-dog
the.quick.brown.fox.jumps.over.the.lazy.dog
the/quick/brown/fox/jumps/over/the/lazy/dog
The Quick Brown Fox Jumps Over the Lazy Dog
The quick brown fox_jumpsover the lazy dog
the quick brown fox_jumpsover the lazy dog
THE QUICK BROWN FOX_JUMPSOVER THE LAZY DOG
By splitting on separators and on the case changes inside a run of letters, so XMLHttpRequest becomes XML, Http and Request rather than one word. That is what makes the conversion survive an input that is already in some other case.
Title case capitalises every word except the small ones in the middle, such as of, the and to. Sentence case capitalises only the first word of each sentence, which is what most interface copy should use.
camelCase for JavaScript variables, PascalCase for components and types, kebab-case for files and CSS, snake_case for database columns, CONSTANT_CASE for environment variables.