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:
- It inserts a split before any uppercase letter that follows a lowercase letter, handling acronyms sensibly (so
parseHTMLStringsplits intoparse,HTML,String). - It then splits on any run of non-alphanumeric characters — spaces, hyphens, underscores, dots.
- 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
| Input | CONSTANT_CASE output |
|---|---|
max retry count | MAX_RETRY_COUNT |
myVariableName | MY_VARIABLE_NAME |
api-base-url | API_BASE_URL |
parseHTMLString | PARSE_HTML_STRING |
DatabaseConnectionTimeout | DATABASE_CONNECTION_TIMEOUT |
next_public_stripe_key | NEXT_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.