Text Tools

Constant Case Converter

Use this free Constant Case Converter to turn any label or identifier into CONSTANT_CASE. It splits camelCase and PascalCase, uppercases every letter, and joins the words with single underscores, the standard form for environment variables and code constants like MAX_RETRY_COUNT. No sign-up required.

Uppercase + Underscores Runs in Browser 100% Free

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.

Everything runs in your browser. Nothing is uploaded or stored.

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.

As an environment variable name

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.
As a code constant

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.
Same spelling, different contract

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

Exporting a Name That Starts With a Digit

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.
Assuming the Uppercase Makes a Value Immutable

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.
Skipping the Framework Prefix

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

Frequently Asked Questions

What is a constant case converter?

A constant case converter is a free online tool that rewrites any text into CONSTANT_CASE, meaning all uppercase letters joined by single underscores. You paste a label or identifier, and it returns a clean CONSTANT_CASE version ready for environment variables and code constants. It splits camelCase and snake_case automatically.

Is CONSTANT_CASE the same as SCREAMING_SNAKE_CASE?

Yes. CONSTANT_CASE, SCREAMING_SNAKE_CASE, and UPPER_SNAKE_CASE are three names for the same format: uppercase words joined by underscores. It is simply snake_case with the letters capitalised, which is why the two conversions share the same word-splitting rules.

How does it handle camelCase and PascalCase?

It detects the capital letters that mark word boundaries and splits the text there, then uppercases everything and joins with underscores. So apiSecretKey becomes API_SECRET_KEY and DatabaseUrl becomes DATABASE_URL.

Will the output always be a valid environment variable?

Not automatically. A portable environment variable name uses only uppercase letters, digits, and underscores and cannot start with a digit. The converter formats the text but does not check this, so a result like 2FA_ENABLED needs a letter prefix before it can be exported.

What happens to numbers and symbols?

Numbers are preserved in place, so s3Bucket becomes S3_BUCKET, and other symbols are removed. Separators such as spaces, hyphens, and dots become underscores, repeated underscores collapse to one, and leading or trailing underscores are trimmed.

Does CONSTANT_CASE make a value read-only?

No. It is a naming convention that signals a value should not change, but no language enforces immutability through the name. Python allows reassignment of uppercase names, and a JavaScript const object still permits property changes. Use the language's own tools for real immutability.

Is my text private when I use this tool?

Yes. The conversion runs entirely in your browser using client-side JavaScript, so nothing you paste is uploaded to a server or stored in a database. That makes it safe for secret key names and internal config you would rather not send anywhere.

When should a developer reach for this constant case converter?

Reach for this constant case converter whenever you are writing a batch of environment variables or code constants and want one consistent style, such as building a .env file, a Docker configuration, or a set of CI secrets. It turns mixed-style names into clean CONSTANT_CASE in seconds and keeps your configuration readable.

Comments

Login to leave a comment

No comments yet. Be the first to comment!