Text Case Converting Keyboard Shortcuts

I put together a set of text-transformation shortcuts for BTT using the “Transform & Replace Selected Text with JavaScript” action. The goal was to create a super-fast workflow for developers, writers, and anyone who edits text all day. I’m currently using ⌃⌥⌘ + letter, shortcuts don’t conflict with any common macOS or app defaults, so they work reliably everywhere. I no longer have a touch bar, but these could easily by modified to work with a set of touch buttons or a floating menu.

text_case_converters.bttpreset (18.1 KB)

This preset lets you select any text and convert it into:
• ⌃⌥⌘U → UPPERCASE
• ⌃⌥⌘L → lowercase
• ⌃⌥⌘T → Title Case
• ⌃⌥⌘C → camelCase
• ⌃⌥⌘P → PascalCase
• ⌃⌥⌘S → snake_case
• ⌃⌥⌘K → kebab-case
• ⌃⌥⌘[SPACEBAR] → Special-characters → spaces
• ⌃⌥⌘- → Special-characters → dashes (-)
• ⌃⌥⌘_ (aka ⌃⌥⌘SHIFT-) → Special-characters → underscores (_)

Each transformation runs through a small JavaScript snippet inside BTT and replaces the original selection automatically — no clipboard juggling, no external apps.

Enjoy!

  • Joe**

Example Text:**
This is some sample TEXT!
It includes: commas, periods... dashes — hyphens - underscores_like_this, andMixedCASEWords.
Also: weird$$characters###like!!!these???and “quotes”, plus multiple spaces.
Check version 2.0 / build#45 @ 3pm.**
**
Example to Upper:
THIS IS SOME SAMPLE TEXT!
IT INCLUDES: COMMAS, PERIODS... DASHES — HYPHENS - UNDERSCORES_LIKE_THIS, ANDMIXEDCASEWORDS.
ALSO: WEIRD$$CHARACTERS###LIKE!!!THESE???AND “QUOTES”, PLUS MULTIPLE SPACES.
CHECK VERSION 2.0 / BUILD#45 @ 3PM.

Example to Lower:
this is some sample text!
it includes: commas, periods... dashes — hyphens - underscores_like_this, andmixedcasewords.
also: weird$$characters###like!!!these???and “quotes”, plus multiple spaces.
check version 2.0 / build#45 @ 3pm.

Example to Title:
This Is Some Sample Text! It Includes: Commas, Periods... Dashes — Hyphens - Underscores_like_this, Andmixedcasewords. Also: Weird$$characters###like!!!these???and “quotes”, Plus Multiple Spaces. Check Version 2.0 / Build#45 @ 3pm.

Example to Camel:
thisIsSomeSampleTextItIncludesCommasPeriodsDashesHyphensUnderscoresLikeThisAndMixedCasewordsAlsoWeirdCharactersLikeTheseAndQuotesPlusMultipleSpacesCheckVersion20Build453pm

Example to Snake:
this_is_some_sample_text_it_includes_commas_periods_dashes_hyphens_underscores_like_this_and_mixed_casewords_also_weird_characters_like_these_and_quotes_plus_multiple_spaces_check_version_2_0_build_45_3pm

Example to Kebab:
this-is-some-sample-text-it-includes-commas-periods-dashes-hyphens-underscores-like-this-and-mixed-casewords-also-weird-characters-like-these-and-quotes-plus-multiple-spaces-check-version-2-0-build-45-3pm

Example to PascalCase:
ThisIsSomeSampleTextItIncludesCommasPeriodsDashesHyphensUnderscoresLikeThisAndMixedCasewordsAlsoWeirdCharactersLikeTheseAndQuotesPlusMultipleSpacesCheckVersion20Build453pm

Example for Space:
This is some sample TEXT It includes commas periods dashes hyphens underscores like this andMixedCASEWords Also weird characters like these and quotes plus multiple spaces Check version 2 0 build 45 3pm

Example for Dash:
This-is-some-sample-TEXT-It-includes-commas-periods-dashes-hyphens-underscores-like-this-andMixedCASEWords-Also-weird-characters-like-these-and-quotes-plus-multiple-spaces-Check-version-2-0-build-45-3pm

Example for Underscore:
This_is_some_sample_TEXT_It_includes_commas_periods_dashes_hyphens_underscores_like_this_andMixedCASEWords_Also_weird_characters_like_these_and_quotes_plus_multiple_spaces_Check_version_2_0_build_45_3pm

Looks great, do you have something for Sentence case as well?

I'm new to BTT and love it but I thought I'd chime in as you've had no response from the OP. To add Sentence case, duplicate one of the hotkeys in the group, change the hotkey to one of your liking and change the transformer Javascript to this:

async function toSentenceCase() {
const clip = await get_clipboard_content({ asBase64: false });
const selection = (await get_selection({ asBase64: false })) || "";
const textToProcess = selection.trim().length > 0 ? selection : clip;

let result = textToProcess.toLowerCase();
result = result.replace(/(^\s*\w|[.!?]\s+\w)/g, (match) => {
return match.toUpperCase();
});
result = result.replace(/\bi\b/g, "I");

await paste_text({
text: result,
insert_by_pasting: true,
});

return "";
}

Don't forget to save it! That it :slight_smile: