Environment variables from a preset to a shippable .env file

Open Tool .env Config Generator

Environment variables from a preset to a shippable .env file

When to use it

Environment variables are usually assembled from old projects and half-remembered notes. Nobody knows which keys are required when the project is handed over, staging is missing one variable while production carries DEBUG=true, and .env.example still holds a real secret. This walkthrough uses Laravel and Next.js to take a config from "it runs" to "it ships".

Variable table filled from a framework preset

It is aimed at backend and full-stack developers who maintain several environments. The output is text only: nothing connects to a server and nothing is written anywhere, so it is safe on a laptop or a corporate network.

Steps

  1. Pick Laravel, choose production as the environment and press Load preset. The table fills with APP_NAME, APP_KEY, APP_ENV, APP_DEBUG, APP_URL, DB_* and CACHE_DRIVER, with secret keys flagged.
  2. Set APP_URL to the real domain and fill the production DB_DATABASE and DB_USERNAME. Press Generate secrets: APP_KEY becomes base64: plus 32 random bytes and the other secret rows get random strings.
  3. Press Generate config and read the score first. Leftover APP_DEBUG=true, out-of-range ports, secrets shorter than 16 characters and unfilled placeholders are listed with deductions. Fix them and regenerate.
  4. Switch the output tabs through .env, .env.example, docker-compose.yml, env.json and env.sh, copying or downloading each. The example file replaces secrets with placeholders and is the only one that belongs in the repository.
  5. To reconcile an existing config, paste that .env into the import box and press Diff. The panel lists missing keys, extra keys, changed values and invalid lines; apply the imported values and run the audit again.

Generated .env output in the export panel

Parameters

Every variable carries six properties: key, value, type, required flag, secret flag and group. The type drives validation. url needs an http or https scheme, email gets a basic format check, host must not contain a scheme, int must be an integer, bool accepts true/false/1/0, enum must match one of the listed options, and secret is checked for length, placeholder words and repeated characters.

Readiness grade with its findings list

Keys use upper-case letters, digits and underscores and may not start with a digit. Duplicate keys are flagged immediately because most dotenv loaders let the last value win, which usually means an unresolved merge conflict.

Port variables must be between 1 and 65535. Booleans accept true, false, 1 and 0, but mixing styles inside one file makes incidents harder to read, so the audit suggests one form.

Secret rows have three masking strategies in the example output: a placeholder such as changeme, an empty value, or a comment describing where the value comes from. The placeholder is the default so a newcomer can see that something must be filled in.

Reading the output

The grade runs A to D. A has no blockers, B has non-fatal notes, C has missing required keys or weak secrets, and D has a setting that will hurt production, such as debug mode on, a placeholder secret or an illegal port.

The .env output is the full file with real values, .env.example is the template for the repository, docker-compose.yml contains only the environment: block, env.json is for programs that read config, and env.sh emits export statements that can be sourced.

The diff makes four judgements: missing (in the template, absent from the file), extra (in the file, absent from the template), changed, and invalid. Invalid lines report their line number in the original file, usually from an unescaped space or a missing equals sign.

Watch the public prefixes: anything starting with NEXT_PUBLIC_ or VITE_ is bundled into the front end and visible to every visitor, so database passwords and server secrets must never live there. The audit warns about that combination separately.

FAQ

Why are the values blank in .env.example? By design. The example file is committed, so it must be masked. Real values belong in the deployment platform's encrypted variables or a secret manager.

The diff reports seven extra keys. Should they be deleted? First check whether they are historical leftovers. Extra keys rarely break anything, but they mislead the next maintainer into thinking they are required.

A secret is flagged even though it is long enough. Why? It may be a placeholder such as changeme, secret or password, or it may have very low character variety like aaaaaaaaaaaaaaaa. Both fall to dictionary attacks almost instantly.

Can the docker-compose output be used as is? Only as the environment: block. Images, ports and volumes are yours to write, and production secrets should come from secrets or an external manager rather than plaintext in the compose file.

The framework preset does not match my project. What now? Presets are a starting point; every framework version adds and removes variables. Compare with the official docs, add rows with the add button and delete what you do not need.

A practical habit when handing a project over: keep the masked example file, a short table of which keys are required per environment, and the exact command that loads the file. The example file alone does not say whether DB_PORT is optional in local development but mandatory in production, and that difference is usually discovered during a deploy. Write the environment matrix once, review it when a variable is added, and delete keys that no longer exist in the code. Rotating a leaked secret is a two-step job: generate a new value here, update the platform's encrypted variable, then restart the service and confirm the old value no longer authenticates. Restarting before the new value is stored is the usual cause of a second outage during the fix.

New in 1.1.0: three delivery formats and sturdier parsing

One variable set now exports straight to a Kubernetes Secret, a GitHub Actions env block and a Terraform tfvars file. Every Secret value is base64 encoded with UTF-8 safety and keys stay uppercase; in Actions, keys ending in SECRET, PASSWORD or TOKEN are written as ${{ secrets.KEY }} so plaintext never lands in the workflow; tfvars lowercases the keys and escapes backslashes and quotes per HCL.

Parsing now covers what real files contain: a leading BOM is ignored, mixed CRLF and LF line endings do not change the result, \n, \t, \" and \u with four hex digits inside double quotes are decoded, single quotes stay literal, and an unquoted value only loses the text after a space followed by #. Multi-line quoted values are read as one value.

Secret reuse detection is new as well. If two variables share the same secret value, the audit warns about it. A rotation that updates one copy and forgets the other is a common outage, and this check exists to catch exactly that.

1.2.0: JSON import, field-level diff and secret entropy

The import box now accepts both a .env file and a JSON object. Paste a configuration in the form { "KEY": "value" }, and the diff action parses it as JSON while the fill action writes the values straight back into the variable table. A JSON syntax error is reported with its reason instead of silently producing an empty file.

The diff result is now a field-level table rather than a list of key names: every changed key shows the current value and the imported value side by side, up to twelve rows, which makes it obvious whether a difference comes from an environment switch or a key rotation.

The secret strength card estimates entropy from the character set (26 lowercase, 26 uppercase, 10 digits, 33 symbols) and adds three rules: length below sixteen, a placeholder such as change, your, example or demo, and the same value used by another variable. Grades run from A to D and the weakest finding is shown in the card header. Entropy is only a lower bound, so the card is meant to expose obvious weaknesses rather than score a passphrase.

1.3.0: env.d.ts, reference checks and platform formats

The most common environment variable accident in a TypeScript project is a misspelled key that only surfaces as undefined at runtime. The new env.d.ts output turns the variable table into readonly ProcessEnv declarations. Put the file at the project root, include it in tsconfig, and a wrong key fails at compile time. The declaration holds key names and types only, never real values.

The reference check targets the ${VAR} form: a value that references a key missing from the table is reported as an error instead of expanding to an empty string during deployment. The rule matches how docker-compose and Kubernetes substitute variables.

Platform format validation in the secret check covers six common credential families: the AKIA prefix and sixteen characters of an AWS access key, the forty characters of an AWS secret, the sk or rk prefix of Stripe, the gh[pousr]_ prefix of GitHub, the xox prefix of Slack, the segmented SG. structure of SendGrid, and the thirty-two hexadecimal characters of a WeChat AppSecret. A mismatch is listed as a problem but does not block generation.

⏫︎