SCREAMING_SNAKE_CASE — all uppercase with underscores — is the standard way to name constants in code and environment variables in shells and config files. This converter rewrites any phrase or identifier into that format.
How it works
The input is split into a list of word tokens, each token is uppercased, and the tokens are joined with underscores. Boundaries come from separators and from case transitions in camelCase or PascalCase input:
"max retry count" -> MAX_RETRY_COUNT
"maxRetryCount" -> MAX_RETRY_COUNT
"max-retry-count" -> MAX_RETRY_COUNT
"databaseUrl" -> DATABASE_URL
Every detected word is uppercased before joining, so the result is always a valid, uppercase, underscore-separated constant name.
Where SCREAMING_SNAKE_CASE is used — and where it is not
The convention is near-universal for a small set of specific situations:
- Environment variables —
DATABASE_URL,STRIPE_SECRET_KEY,API_BASE_URL. Both POSIX shells and Docker/Kubernetes env configs treat all-caps as the de facto standard. Mixing cases here causes subtle bugs: on LinuxPortandPORTare two different variables. - Compile-time constants — C macros (
#define MAX_BUFFER_SIZE 4096) and Rust constants (const MAX_RETRY_COUNT: u32 = 5) use this form by convention. The uppercase visually signals “this value does not change at runtime.” - Enum members in some languages — Java and older Python codebases use
SCREAMING_SNAKE_CASEfor enum values; modern Python (3.11+)StrEnumand Rust enums prefer PascalCase, so check your language’s style guide. - Configuration keys in shell scripts — if you are writing a
.envfile loaded bydotenv, bashsource, or a CI/CD pipeline, uppercase is expected.
Do not use SCREAMING_SNAKE_CASE for function names, local variables, class names, or filenames — those contexts each have their own conventions.
Common mistakes
- Abbreviations: if your phrase includes an abbreviation like “HTTP” or “URL”, the converter keeps it as-is.
httpStatusCodebecomesHTTP_STATUS_CODE. Verify the result reads as you expect. - Numbers and version strings: a phrase like
v2 api endpointmay tokenise the2as a separate fragment. Review the output and manually merge the digit into the adjacent word if your style guide requiresV2_API_ENDPOINTrather thanV_2_API_ENDPOINT. - Leading/trailing underscores: some conventions reserve a leading underscore (
_INTERNAL_ONLY) for private or internal constants. The converter does not add one — append it manually if your codebase uses that pattern.
Tips and notes
This format clearly signals immutability, which is why it is reserved for constants and configuration. On Unix-like systems environment variable names are case sensitive, so keeping them uppercase avoids collisions between names that differ only in case. Letters and digits are separated during tokenisation; rejoin a segment like a version number after copying if you prefer it attached.