CONSTANT_CASE Converter

Convert any phrase into CONSTANT_CASE (also called SCREAMING_SNAKE_CASE) — all uppercase letters joined by underscores. Standard for environment variables and constants.

Example: max retry attemptsMAX_RETRY_ATTEMPTS

CONSTANT_CASE (also widely known as SCREAMING_SNAKE_CASE or UPPER_SNAKE_CASE) is the convention where words are uppercase and joined by underscores. It's the universal style for environment variables, named constants, C/C++ macros, and (historically) enum members.

The visual loudness — all caps plus separators — signals to readers that the value is special: globally scoped, immutable, or compile-time. Most languages don't enforce the convention but every team picks it up because it makes constants distinguishable at a glance.

When to use it

Environment variables

DATABASE_URL, STRIPE_SECRET_KEY, NODE_ENV. POSIX env-var names are conventionally CONSTANT_CASE; many shells reject lowercase env-var names entirely.

Named constants

MAX_RETRIES = 3, DEFAULT_TIMEOUT_MS = 5000, PI = 3.14159. Per Python's PEP 8, JavaScript convention, and most C/C++ style guides, top-level constants are CONSTANT_CASE.

C and C++ macros

#define MAX_BUFFER 4096 — preprocessor macros are CONSTANT_CASE to make them visually distinct from regular identifiers (since they're substituted at compile time, not evaluated like normal code).

Configuration keys

Some configuration formats (especially older Unix tools and .env files) use CONSTANT_CASE keys: LOG_LEVEL=debug, HTTP_PORT=8080.

Legacy enum values

Older C++ and Java code uses CONSTANT_CASE for enum members (OrderStatus.PENDING); modern style guides prefer PascalCase for enum values.

How the conversion works

The tool converts input text to CONSTANT_CASE by first splitting on any non-alphanumeric delimiter (whitespace, hyphens, dots, underscores, etc.) into words. Each word is then converted to uppercase using the Unicode uppercase mapping (covers ASCII and accented Latin). Finally, the words are joined with a single underscore _. The algorithm preserves digits but strips leading/trailing delimiters. For example, 'v2.0-beta' becomes V2_0_BETA. Consecutive delimiters are collapsed into one underscore. The transformation is locale-independent, treating all letters via the standard toUpperCase JavaScript method.

How to use it

  1. Enter or paste your phrase into the input box.
  2. Click the 'Convert' button to apply CONSTANT_CASE formatting.
  3. Copy the result from the output area.
  4. Use the converted string in your code (environment variables, constants, etc.).

Edge cases this converter handles

Acronyms
Acronyms like 'NASA' remain unchanged after upper-casing (they were already uppercase).
Hyphenated words
Hyphens are treated as delimiters, so 'high-level' becomes 'HIGH_LEVEL'.
Numbers and special chars
Numbers are kept; non-alphanumeric characters (except underscores) are replaced with underscores, and multiple underscores collapse to one.
Empty input
Empty input returns an empty string, and a string with only delimiters returns an empty string.

Pro tips for case conversion

  • Use CONSTANT_CASE for all environment variable names (e.g., MAX_CONNECTIONS) to follow established conventions.
  • For SQL column aliases, apply CONSTANT_CASE to avoid quoting issues in legacy systems.
  • If your input contains already-uppercase acronyms, the tool still works fine—just it will stay uppercase.
  • To revert CONSTANT_CASE back to normal, split on '_' and lowercase each word, then join with spaces.

vs other ways to change case

While CONSTANT_CASE is straightforward, developers often use command-line or programming tools for the same effect.

This toolsed commandPython one-liner
UI simplicityWeb-based, no install neededRequires terminal, basic UnixRequires Python installation
Real-time previewYes, instant conversionNo, must re-run after editNo, manual execution each time
Handling of complex inputSplits on all non-alphanumericRelies on regex, can be tunedFlexible with regex but needs coding
Batch processingSingle string onlyCan process files line by lineCan process files with script

A bit of history

CONSTANT_CASE, often called UPPER_SNAKE_CASE or SCREAMING_SNAKE_CASE, emerged with early programming languages like C, where preprocessor macros (e.g., #define MAX_SIZE 100) were conventionally written in all caps with underscores. The Unix shell also adopted this style for environment variables (e.g., PATH, HOME). The term 'SCREAMING_SNAKE_CASE' was later popularized in the Ruby and Python communities to describe this visually loud naming convention.

Common questions about case conversion

Is CONSTANT_CASE the same as SCREAMING_SNAKE_CASE?

Yes — they're synonyms. "CONSTANT_CASE" is preferred in formal style guides; "SCREAMING_SNAKE_CASE" is the more memorable name programmers actually use in conversation. Both refer to identical output.

When should I NOT use CONSTANT_CASE?

For values that look constant but are actually re-assignable (let x = 1 in JavaScript), use the language's variable convention instead. Reserve CONSTANT_CASE for values that are genuinely immutable: literal constants, env-var names, and compile-time macros.

Why are environment variables conventionally uppercase?

Historical: early Unix shells reserved lowercase names for shell-local variables and uppercase for exported (environment) variables. The convention stuck even after the technical distinction blurred.

Can I have lowercase environment variables?

POSIX shells allow them, but most tooling (Docker, Kubernetes, CI systems, twelve-factor app config) assumes uppercase. Stick with CONSTANT_CASE to avoid edge-case bugs.

Embed our tools on your website

Free for any site. No signup. Iframe loads from our servers and stays up-to-date automatically.

📋 Embed the Word Counter

Copy this snippet:

Live preview:

📋 Embed this CONSTANT_CASE Converter

Copy this snippet:

Live preview:

Want more options? All embeddable tools →