Developer Tools

Convert to CONSTANT_CASE

Convert selected words or identifiers to CONSTANT_CASE.

OfficialOn-device

Download action

What Convert to CONSTANT_CASE does

Splits mixed identifiers into words, joins them with underscores, and uppercases the result for constants and environment keys.

CategoryDeveloper Tools
Action typeJavaScript
ResultReplace or copy text
InternetNot required

Action and outcome

Convert to CONSTANT_CASE example
ActionOutcome
Convert to CONSTANT_CASESelected text: HTTP response codeHTTP_RESPONSE_CODE

Use Convert to CONSTANT_CASE

Follow these steps to convert selected words or identifiers to CONSTANT_CASE with ActionClip.

  1. Select the text you want to use.
  2. Choose Convert to CONSTANT_CASE from ActionClip.
  3. Review the result, then replace the selection or copy the new text.

Requirements and privacy

  • Before you start: No setup required.
  • Your selected text: Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.

Action configuration

The definition below is included so you can inspect how the action works before downloading it.

JavaScript definition
function run(selected_text) {
  const words = selected_text
    .normalize("NFKD")
    .replace(/\p{M}+/gu, "")
    .replace(/([A-Z\d]+)([A-Z][a-z])/g, "$1 $2")
    .replace(/([a-z\d])([A-Z])/g, "$1 $2")
    .replace(/[^\p{L}\p{N}]+/gu, " ")
    .trim()
    .split(/\s+/)
    .filter(Boolean)
    .map((word) => word.toLowerCase());

  if (!words.length) return "";
  const capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
  return words.join("_").toUpperCase();
}