Skip to content
koducathome

Environment Variable Formatter

Clean up .env files — sort, deduplicate and quote values — and convert them to JSON, Docker or Kubernetes formats.

How to use this tool

Steps for using the Env Formatter.

  1. Paste a .env file into the input, click Upload .env, or click Sample. Keys, values, comments and export are colour-coded as you type.
  2. Pick a target under Convert to: .env, JSON, shell export lines, docker run -e flags, a Compose environment: block, a Kubernetes env: list, a ConfigMap or a K8s Secret (give the manifest a Name).
  3. Toggle Sort keys, Remove duplicates, Remove comments, Normalize quotes and Uppercase keys, or turn on .env.example to keep the keys but empty every value.
  4. Set Mask to *Secrets only* to hide passwords, tokens, keys and URLs with credentials, or *All values* before sharing the output.
  5. Switch the output to Table to see every variable with its line, value and notes (secret, overridden, export, invalid key). Click an issue or a line number to jump to it in the input.
  6. Copy, Download or Expand the result. Everything runs in your browser — values are never uploaded or sent to analytics.

Example

Convert a .env file to a Kubernetes env list

.env (Remove duplicates enabled)
export NODE_ENV=production
APP_NAME="My App"
PORT=3000 # web port
PORT=8080
Kubernetes env YAML
env:
  - name: NODE_ENV
    value: "production"
  - name: APP_NAME
    value: "My App"
  - name: PORT
    value: "8080"

Common use cases

  • Turning a local .env into the env: section of a Kubernetes Deployment or the environment: block of a docker-compose file.
  • Finding the duplicate key that makes a value differ between your machine and CI.
  • Generating docker run -e flags for a quick one-off container.
  • Sorting and normalising a team's .env.example before committing it.
  • Sharing a masked copy of configuration in a bug report or support chat.

How .env files are parsed

A .env file is a list of KEY=value lines. There is no formal standard, so this tool follows the rules shared by the popular dotenv libraries and Docker Compose: blank lines and lines starting with # are ignored, an optional export prefix is allowed (so the same file can be sourced by a shell), and whitespace around the key and value is trimmed. For unquoted values, a # preceded by whitespace starts an inline comment — PORT=3000 # web port gives 3000, while COLOR=#fff keeps the hash.

Quoting changes how the value is read. Single quotes keep the content literally. Double quotes process escape sequences — \n becomes a newline, \" a quote — and may span several lines, which is how private keys and certificates are usually stored. Variable names must match [A-Za-z_][A-Za-z0-9_]*; names such as 2FA_SECRET or API-KEY are rejected by shells and most loaders, so they are reported and left out of the converted output.

When a key appears more than once, the last definition wins in dotenv, Docker and Compose — the issue list tells you which line that is, and Remove duplicates keeps exactly that one. Normalize quoting rewrites values with the least quoting that is still unambiguous: plain values stay bare, values with spaces or special characters get single quotes, and values containing newlines or single quotes get double quotes with escapes.

Conversions are generated so they can be pasted as-is. JSON uses a flat object of strings. docker run flags are POSIX shell-quoted, so values with spaces, quotes or $ survive the shell. Compose and Kubernetes YAML always double-quote values, because unquoted true, yes, 0755 or 8080 would otherwise be parsed as booleans or numbers, which Kubernetes rejects for env values. Mask values replaces each value with its first two characters plus ***, so you can share a file's structure in a ticket without leaking secrets.

Limitations

  • Variable expansion (${OTHER_VAR}) is not performed; values are kept literally. Note that Docker Compose interpolates $ in YAML values — write $$ for a literal dollar sign.
  • Backtick-quoted values are treated like single-quoted values (no escapes).
  • Kubernetes output produces plain name/value pairs; it does not create Secrets, ConfigMaps or valueFrom references.
  • Input is limited to 2 million characters.

Frequently asked questions

Is my .env file uploaded anywhere?

No. Parsing, formatting and conversion run entirely in your browser. Values are never sent to a server or to analytics. Use Mask values before sharing the output with anyone.

Should values in a .env file be quoted?

Only when needed: values with spaces, #, quotes or newlines should be quoted so every loader reads them the same way. Use single quotes for literal text and double quotes when you need escapes such as \n.

Which value wins when a key is defined twice?

The last one, in dotenv, Docker --env-file and Docker Compose. The tool reports every duplicate with the line that wins.

How do I put these variables into a Kubernetes Secret instead?

Use kubectl create secret generic my-secret --from-env-file=.env, then reference it with envFrom. This tool's Kubernetes output is for plain, non-sensitive env entries. Validate the resulting manifest with the YAML Validator.

Can I convert JSON back to a .env file?

Not in this tool — it reads .env input. For other format conversions see the JSON to YAML converter.