.env Example Generator

Generates a .env template with the variables your stack expects, so a new developer knows what to fill in. The template is committed; the filled-in file never is.

Live demo · real result from this tool
Values

.env.example

# Copy to .env and fill in real values. Never commit .env. # DatabaseDATABASE_URL=postgres://user:password@localhost:5432/app # StripeSTRIPE_SECRET_KEY=change-meSTRIPE_WEBHOOK_SECRET=change-mePORT=3000NEXT_PUBLIC_API_URL=https://api.example.com 

Commit .env.example; keep .env in .gitignore. If a real secret was ever committed, rotate it — deleting it does not remove it from history.

Processed on your device — nothing is uploaded.

How to use .env Example Generator

  1. Select your stack and the services you use.
  2. Save the generated template as .env.example and commit it.
  3. Copy it to .env, fill in real values, and confirm .env is git-ignored.
  4. Add .env to .gitignore before the first commit, not after.
  5. Variables prefixed NEXT_PUBLIC_, VITE_ or REACT_APP_ are compiled into the client bundle.
  6. Restart the dev server after changing .env — most frameworks read it only at startup.

Commit .env.example, never .env

The convention that works: a committed .env.example listing every variable name with a placeholder or empty value, and a git-ignored .env holding the real ones. That gives a new developer a complete checklist without exposing anything, and it documents the configuration surface in the repository where it belongs. The failure mode is a .env committed once early in a project’s life — which puts the secrets in the history permanently, where ignoring the file afterwards does nothing.

If a secret was committed, rotate it

Removing it from the working tree does not remove it from history, and rewriting history means force-pushing every commit and breaking every clone — and forks, caches and third-party mirrors may keep a copy regardless. Assume anything pushed to a remote is compromised and rotate the credential. That is faster, more certain, and does not require coordinating with everyone who has cloned the repository.

Environment variables are not encrypted

They are readable by any process running as the same user, they appear in crash dumps and in some logging setups, and on a shared host they may be visible in the process table. They are a reasonable place for configuration and moderate secrets, and a poor place for anything truly sensitive in a shared environment. Production systems of any scale should use a secrets manager — Vault, AWS Secrets Manager, or the platform’s own — which adds rotation, audit logging and access control that a file cannot.

The client-side prefix that catches people out

Build tools expose variables to browser code only when prefixed: NEXT_PUBLIC_ in Next.js, VITE_ in Vite, REACT_APP_ in Create React App. That is a safety mechanism, and it cuts both ways — a secret accidentally given one of those prefixes is compiled into the JavaScript bundle and shipped to every visitor. Anything with PUBLIC in its name should be treated as published, because it is.

Frequently asked questions

Should I commit the generated file to git?
Yes, commit .env.example with placeholder values so teammates know what to set — but keep your actual .env with real secrets in .gitignore.
Can I use this config file as-is in my project?
Yes, as a starting point — adjust the values to match your actual project structure and tooling versions.
Is this config validated against the real tool's schema?
It follows the tool's documented format, but always run your build once after adding it to confirm your specific setup is happy.
Should I commit my .env file?
Never. Commit a .env.example with the variable names and placeholder values so others know what to configure, and keep the real .env git-ignored. A committed .env puts secrets in the history permanently.
I accidentally committed a secret. What do I do?
Rotate it immediately — treat it as compromised. Removing it from history requires rewriting every commit and force-pushing, which breaks clones and still may not reach forks and caches. Rotation is faster and actually works.
Are environment variables secure?
Adequately for configuration, not for high-value secrets on shared infrastructure. They are readable by processes under the same user and can leak into crash dumps and logs. Use a secrets manager for production, which adds rotation and audit trails.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close