Caseflip JavaScript snippet

Hey everyone, I just joined the group because I’ve been sitting on this caseflip snippet for years and didn’t have anywhere to share it. This thing cycles your clipboard text through lowercase, Title Case, and all caps with one trigger.

Take ‘hello world’—type caseflip, and it’s ‘Hello World’. Again, ‘HELLO WORLD’. One more, back to ‘hello world’. I’ve been using it forever now.

Here’s the code if you want to try it:

var text = '%clipboard';
if (text === text.toUpperCase()) {
    text.toLowerCase();
} else if (text === text.toLowerCase()) {
    text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
} else {
    text.toUpperCase();
}

Set it as caseflip in TextExpander, and that’s it. Thought this crew might get some use out of it.

3 Likes

@acarter this snippet is great! Just added it to my library. Thanks for sharing!

1 Like

Rad! Thanks for the share @acarter!

1 Like