Case Converter→Specialized Version
🔤

Constant Case Converter

Convert text to SCREAMING_SNAKE_CASE

Acronyms split the way programmers expect: XMLHttpRequest becomes xml_http_request, not x_m_l_http_request.

Constant Case Converter

SCREAMING_SNAKE_CASE writes HELLO_WORLD_EXAMPLE. Constant case is the near-universal convention for environment variables and compile-time constants: DATABASE_URL, MAX_RETRY_COUNT, HTTP_TIMEOUT_MS. Shells, Docker, Kubernetes and every twelve-factor deployment tool expect it, and POSIX reserves all-caps names for the environment specifically so they cannot collide with shell variables.

Conversions

InputSCREAMING_SNAKE_CASE
hello world exampleHELLO_WORLD_EXAMPLE
XMLHttpRequestXML_HTTP_REQUEST
user_first_nameUSER_FIRST_NAME
Total Order CountTOTAL_ORDER_COUNT
Everything upper-cases, so acronyms are indistinguishable from words: XMLHttpRequest becomes XML_HTTP_REQUEST. The conversion is lossy in one direction — DB_URL could have come from dbUrl or DBUrl, and nothing in the output says which.

The Same Text in Other Cases

CaseResult
camelCasehelloWorldExample
PascalCaseHelloWorldExample
snake_casehello_world_example
kebab-casehello-world-example
Train-CaseHello-World-Example
dot.casehello.world.example

What Actually Belongs in a Constant

A constant is a value fixed at compile time and meaningful by name rather than by number — MAX_RETRY_COUNT, DEFAULT_TIMEOUT_MS, HTTP_PORT. Naming it removes the magic number and gives the reason for the value somewhere to live.

The convention is near-universal, which is why it carries safely across a codebase mixing several languages. Where it breaks down is in languages treating capitalisation as semantics: in Ruby every capitalised identifier is a constant, and in Go a capitalised one is exported.

Converting in Code

``javascript const constant = (s) => words(s).map((w) => w.toUpperCase()).join('_'); `

POSIX permits only letters, digits and underscore in an environment variable name, and forbids a leading digit. A converter that faithfully preserves a hyphen produces a name the shell silently ignores rather than rejects.

Converting at the API Boundary

The recurring friction is that JavaScript uses camelCase and Python, Ruby, Go and SQL use snake_case. The fix is to convert in exactly one place — the client that talks to the API — rather than letting both conventions into the same codebase.

`javascript const toCamel = (s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase()); const toSnake = (s) => s.replace(/[A-Z]/g, (c) => '_' + c.toLowerCase());

// Recursively, for a whole payload const convertKeys = (value, fn) => Array.isArray(value) ? value.map((v) => convertKeys(v, fn)) : value && typeof value === 'object' ? Object.fromEntries(Object.entries(value).map(([k, v]) => [fn(k), convertKeys(v, fn)])) : value; `

Two things to watch: keys that are user data rather than field names must not be converted, and the round trip is not always lossless — userID → user_id → userId changes the original.

Where Each Convention Is Mandatory

Not stylistic — these will break if you deviate:

ContextRequirement
Environment variablesUppercase with underscores; POSIX reserves lowercase
Custom HTML elementsMust contain a hyphen
Python modulesCannot contain hyphens; the import statement will not parse
SQL identifiersFolded to one case unless quoted, so camelCase does not survive
React componentsMust start uppercase, or JSX treats it as an HTML tag

Renaming Safely

A find-and-replace across a codebase will hit strings, comments and unrelated identifiers. Use your language server's rename symbol instead — it understands scope. For a bulk rename across files, restrict the pattern with word boundaries and review the diff before committing:

`bash grep -rn '\buserId\b' src/ # look first ``

Frequently Asked Questions

When should I use SCREAMING_SNAKE_CASE?

Constant case is the near-universal convention for environment variables and compile-time constants: `DATABASE_URL`, `MAX_RETRY_COUNT`, `HTTP_TIMEOUT_MS`. Shells, Docker, Kubernetes and every twelve-factor deployment tool expect it, and POSIX reserves all-caps names for the environment specifically so they cannot collide with shell variables.

How are acronyms handled?

Correctly. `XMLHttpRequest` becomes `XML_HTTP_REQUEST`, treating the run of capitals as one word rather than splitting every letter.

Does the converter handle numbers and punctuation?

Numbers stay attached to the word they belong to; punctuation and separators are treated as word boundaries and removed. `order-2-total` and `order_2_total` both produce the same words.

Related Tools

Explore other tools you might find useful:

More Case Converter tools

You might also need