Constant Case Converter

Turn any text into 'CONSTANT_CASE' for env vars and constants.

Free CONSTANT_CASE converter for developers. Paste any text and get uppercase underscore-separated output for environment variables and constants. Runs entirely in your browser — nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is CONSTANT_CASE?

CONSTANT_CASE — also called SCREAMING_SNAKE_CASE — writes words in uppercase separated by underscores, like 'MAX_RETRY_COUNT'. It is the convention for environment variables and named constants in many languages.

This converter turns any text into CONSTANT_CASE — also called SCREAMING_SNAKE_CASE — where every word is uppercase and joined by underscores, like MAX_RETRY_COUNT. It is the conventional format for environment variables and named constants in JavaScript, TypeScript, Python, Go, Rust, Java and most other mainstream languages.

When you need this

The most common scenario is defining .env file keys or referencing process.env values: environment variable names must be uppercase and use underscores as separators. If you are copying a config key from a design document written in plain English (“api base url”) or from a JSON property name (“apiBaseUrl”), you need it in API_BASE_URL form before you can paste it into a Dockerfile, a shell script, or a cloud provider’s environment settings panel.

Other common uses:

  • Converting a kebab-case CSS custom property name to a JavaScript constant.
  • Normalising configuration keys before writing a shared constants file.
  • Porting names from a camelCase TypeScript interface into a Go or Python constants module.
  • Quickly cleaning up keys copied from API documentation that mixes naming styles.

How it works

The converter detects word boundaries in your input regardless of its original style:

  1. It inserts a split before any uppercase letter that follows a lowercase letter, handling acronyms sensibly (so parseHTMLString splits into parse, HTML, String).
  2. It then splits on any run of non-alphanumeric characters — spaces, hyphens, underscores, dots.
  3. Each resulting word is uppercased and the words are joined with _.

This handles plain text, camelCase, PascalCase, snake_case and kebab-case in a single pass.

Conversion examples

InputCONSTANT_CASE output
max retry countMAX_RETRY_COUNT
myVariableNameMY_VARIABLE_NAME
api-base-urlAPI_BASE_URL
parseHTMLStringPARSE_HTML_STRING
DatabaseConnectionTimeoutDATABASE_CONNECTION_TIMEOUT
next_public_stripe_keyNEXT_PUBLIC_STRIPE_KEY

Edge cases to know

Acronyms: The converter treats a run of consecutive capitals as a single word boundary, so XMLParser becomes XML_PARSER and parseHTTPRequest becomes PARSE_HTTP_REQUEST. If you are converting a name with an ambiguous acronym, check the output once before pasting.

Leading or trailing separators: Extra hyphens, spaces or underscores at the start or end of your input are stripped, so --my-key-- becomes MY_KEY cleanly.

Numbers: Digits are kept as part of the surrounding word unless separated, so v2ApiEndpoint becomes V2_API_ENDPOINT and endpoint2 becomes ENDPOINT2.

Everything runs in your browser, so your code never leaves your machine.