Constant Case Converter
Convert text to CONSTANT_CASE for constants and environment variable names, with the naming rules that apply.
Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.
What the Constant Case Converter does
The constant case converter on this page will convert text to CONSTANT_CASE for constants and environment variable names, with the naming rules that apply. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for naming an environment variable for a config value. Companion tools to this one live on FreeToolsWorld.org.
How to use it
- Paste or type your text into the input box.
- The target case is already selected — change it from the dropdown if you need a different one.
- The converted text appears immediately as you type.
- Press Copy to put the result on your clipboard.
How it works
CONSTANT_CASE — uppercase words joined by underscores, sometimes called screaming snake case — marks a value as a constant in almost every language that has a convention for it, and is the standard form for environment variable names.
Environment variables have real constraints beyond style. POSIX allows only uppercase letters, digits and underscores in the portable character set, and a name must not start with a digit. Lowercase names and hyphens work in some shells and fail in others, so sticking to the portable form avoids a class of bug that only appears on another machine.
By convention, variables intended for the shell's own use are uppercase and user variables in scripts are lowercase, precisely so the two do not collide. That is a convention rather than a rule, but ignoring it is how a script accidentally overwrites PATH.
When to use it
- Naming an environment variable for a config value.
- Declaring a constant in code.
- Generating a .env file key from a description.
- Converting a config key between conventions.
Common mistakes to avoid
- Starting an environment variable name with a digit, which is invalid.
- Using a hyphen, which works in some shells and breaks in others.
- Overwriting a reserved shell variable such as PATH, HOME or IFS.
Frequently asked questions
What is CONSTANT_CASE?
Uppercase words joined by underscores: MAX_RETRY_COUNT. It marks constants in code and is the standard form for environment variable names.
What characters are allowed in an environment variable name?
Portably, uppercase letters, digits and underscores, not starting with a digit. Other characters work in some shells and fail in others.
Why are environment variables uppercase?
Convention, to keep them visually distinct from ordinary shell variables and reduce the chance of a script accidentally shadowing one.