Why You Are Here
You are writing a .env file. Environment variables are written in CONSTANT_CASE by near-universal convention, and you want a batch of them, DATABASE_URL, API_SECRET_KEY, REDIS_HOST, in one consistent style.
You are defining constants in code. A group of fixed values, MAX_RETRY_COUNT, DEFAULT_TIMEOUT, PI, that should stand out from ordinary variables at a glance.
You are moving names between styles. A set of camelCase or snake_case keys that need to become CONSTANT_CASE before they go into a config loader, a Dockerfile, or a CI secret store.
What This Tool Does
The Constant Case Converter rewrites any text as CONSTANT_CASE, meaning all uppercase letters joined by single underscores. Paste a word, a phrase, or an existing identifier, click convert, and it returns output ready for environment variables, config keys, and code constants.
CONSTANT_CASE Names Two Different Things
The format looks like one thing, but it is used for two, and the two follow different rules. Understanding which one you are producing is the difference between a name that works and one that silently fails.
DATABASE_URL, PORT, NODE_ENV. Here CONSTANT_CASE is not a style preference, it is close to a requirement, and the operating system has real rules about what a valid name looks like.
MAX_RETRY_COUNT, PI, DEFAULT_TIMEOUT. Here the uppercase is a convention, a signal to other developers that the value should not change. No language enforces immutability through the name itself.
The identical string MAX_CONNECTIONS is a hard-ruled shell variable in one place and a soft-convention constant in another. The converter produces the text, you decide which contract applies.
What Happens to Each Kind of Input
Predict the output before you paste. CONSTANT_CASE is exactly snake_case in uppercase, so the splitting rules match, only the final casing differs.
|
Input pattern |
You type | You get | What happened |
|
Plain words |
Max Retry Count |
MAX_RETRY_COUNT |
Spaces to underscores, uppercased |
|
camelCase |
apiSecretKey |
API_SECRET_KEY |
Split at each capital, uppercased |
|
PascalCase |
DatabaseUrl |
DATABASE_URL |
Split at each capital, uppercased |
|
snake_case |
redis_host |
REDIS_HOST |
Underscores kept, letters uppercased |
|
kebab-case |
node-env |
NODE_ENV |
Hyphens to underscores |
|
dot.case |
app.timeout |
APP_TIMEOUT |
Dots to underscores |
|
Acronym run |
HTTPProxyHost |
HTTP_PROXY_HOST |
Acronym kept whole, then split |
|
Numbers |
s3Bucket2 |
S3_BUCKET2 |
Digits stay in place |
|
Leading digit |
2faEnabled |
2FA_ENABLED |
Valid text, invalid as an env var |
|
Messy spacing |
Api Key |
API_KEY |
Spaces collapsed, edges trimmed |
The leading-digit row is the one to watch
2FA_ENABLED is clean CONSTANT_CASE and a valid code constant name in many languages, but it is not a valid environment variable name, because names cannot begin with a digit.
Environment Variable Names Have Real Rules
This is the honest limit of the tool, and the section most converters skip. CONSTANT_CASE formatting does not guarantee a valid environment variable, because the shell has rules the converter does not check.
The POSIX rule
A portable environment variable name uses only uppercase letters, digits, and underscores, and must not start with a digit. So 2FA_ENABLED and 3D_MODE are formatted correctly yet rejected as environment variables. Prefix them, TWO_FA_ENABLED or APP_2FA_ENABLED, to make them valid.
Names are case sensitive
PATH and path are two different variables on Linux and macOS. CONSTANT_CASE avoids the confusion by keeping everything uppercase, which is exactly why the convention exists.
Dots and hyphens do not survive
app.timeout and app-timeout are not exportable as-is in bash, which is another reason environment names collapse to underscores. The converter does this for you, turning both into APP_TIMEOUT.
Check the first character before you export
If the output begins with a digit, add a letter prefix. It is the single most common reason a freshly generated variable name is rejected by the shell.
CONSTANT_CASE in .env and Config
Where CONSTANT_CASE shows up in day-to-day work, and why prefixing matters.
| Context | Typical CONSTANT_CASE name |
|
.env files |
DATABASE_URL, STRIPE_SECRET_KEY |
|
Docker and docker-compose |
POSTGRES_PASSWORD, NODE_ENV |
|
Kubernetes ConfigMaps and Secrets |
REDIS_HOST, LOG_LEVEL |
|
CI/CD secrets |
AWS_ACCESS_KEY_ID, DEPLOY_TOKEN |
Prefixing prevents collisions
Frameworks read environment variables by name, and generic names collide. Vite only exposes variables starting with VITE_, Create React App uses REACT_APP_, and many teams prefix everything with APP_ to keep their config separate from the operating system's own variables. Convert the name, then add the prefix.
In Code, It Is a Convention, Not a Guarantee
The uppercase says do not change this, but the language rarely enforces it. Knowing that keeps expectations honest.
Python has no true constants
Writing MAX_RETRY = 5 in uppercase is a signal to other developers, nothing more. Python will let any code reassign it. The convention works because people respect it, not because the interpreter blocks the change.
JavaScript const is a binding, not deep immutability
const MAX = 5 cannot be reassigned, but const CONFIG = {} still allows CONFIG.value to change. The uppercase name signals intent; const controls only the binding, not the contents.
So CONSTANT_CASE communicates, it does not protect
Treat it as documentation aimed at humans. The value's actual immutability comes from how the code is written, not from the shape of the name.
CONSTANT_CASE and Its Siblings
CONSTANT_CASE is snake_case in uppercase, so if you need the lowercase form for a Python variable or a database column, switch it with the Snake Case Converter
|
Style |
Example | Separator | Casing | Best for |
|
CONSTANT_CASE |
MAX_RETRY_COUNT |
Underscore |
all uppercase |
Env vars, constants |
|
snake_case |
max_retry_count |
Underscore |
all lowercase |
Python, Ruby, SQL |
|
camelCase |
maxRetryCount |
none |
mid-word capitals |
JavaScript, Java |
|
kebab-case |
max-retry-count |
Hyphen |
all lowercase |
URLs, CSS, slugs |
|
dot.case |
max.retry.count |
Dot |
all lowercase |
Config keys, i18n |
Which Case to Use Where
| Situation | Convention to use |
|
Environment variables |
CONSTANT_CASE |
|
Code constants and enums |
CONSTANT_CASE |
|
Python and SQL identifiers |
snake_case |
|
JavaScript variables |
camelCase |
|
Config and i18n keys |
dot.case |
|
URLs and slugs |
kebab-case |
Match the destination
CONSTANT_CASE belongs where a value is fixed or lives in the environment. For anything the code reads as an ordinary variable, one of the lowercase styles fits better.
Common Mistakes to Avoid
2FA_ENABLED is clean CONSTANT_CASE but an illegal environment variable, because names cannot begin with a number. The shell rejects it, often with a confusing error. Add a letter prefix, such as APP_2FA_ENABLED, before exporting.
CONSTANT_CASE is a convention, not a lock. Python will happily reassign an uppercase name, and a const object in JavaScript can still have its properties changed. Rely on the language's actual immutability features, not on the shape of the name.
A variable named simply KEY or HOST collides with other config and may be ignored by tools that only read prefixed names, like VITE_ or REACT_APP_. Convert the base name, then add the prefix your framework expects.
Quick Reference
| Item | Detail |
|
Separator |
Single underscore |
|
Letter casing |
All uppercase |
|
Splits on |
Spaces, hyphens, dots, capital-letter boundaries |
|
Numbers |
Preserved in place |
|
Symbols |
Removed |
|
Repeated underscores |
Collapsed to one |
|
Edge underscores |
Trimmed |
|
Env-var rule |
No leading digit, letters/digits/underscore only |
|
In code |
A convention, not enforced immutability |
|
Best for |
Environment variables, constants, config keys |
|
Runs |
100% in the browser, nothing uploaded |
