.env · workflow🔒 100% client-side — never leaves your browser

.env.example Generator

Generate a .env.example file from your real .env: this .env.example generator removes every secret value, keeps the keys, comments, blank lines and export prefixes, and gives you a template that is safe to commit.

By Aliniyaz Mamat · last reviewed

Be the first to rate
# Database
DATABASE_URL=

# App
NODE_ENV=development
PORT=3000
JWT_SECRET=
STRIPE_SECRET_KEY=

Key takeaways

  • ✓Every value is emptied except an allow-list of 8 harmless settings (NODE_ENV, PORT, DEBUG, LOG_LEVEL, APP_ENV, RAILS_ENV, PYTHON_ENV, ENVIRONMENT), and you can switch that off too.
  • ✓Comments and blank lines stay in place, so section headings like # Database document the file for the next developer.
  • ✓Lines that are not KEY=value or a comment (for example the middle of a multi-line private key) are dropped, so no secret material slips through.
  • ✓.env.example belongs in git; .env never does.

What it does

  • ▸Empties all values, keeps keys, comments, blank lines and export
  • ▸Optional: keep values of non-secret keys like NODE_ENV and PORT
  • ▸Optional: sort keys alphabetically
  • ▸Drops stray lines that could hold secret material
  • ▸Copy or download as .env.example, 100% client-side

Privacy

Runs 100% in your browser. Your .env never touches our servers.

client-side only

Usage examples

Case 1 · Values removed, comments kept
# Database
DATABASE_URL=postgres://app:pw@db/app

# Auth
JWT_SECRET=4f9c2e…
# Database
DATABASE_URL=

# Auth
JWT_SECRET=
Case 2 · Safe defaults kept
NODE_ENV=development
PORT=3000 # http port
STRIPE_SECRET_KEY=sk_test_51H…
NODE_ENV=development
PORT=3000 # http port
STRIPE_SECRET_KEY=
Case 3 · export and multi-line keys
export API_TOKEN=abc123
PRIVATE_KEY="-----BEGIN KEY-----
MIIEvQIBADANBg…
-----END KEY-----"
export API_TOKEN=
PRIVATE_KEY=

When to use this tool

  • →A repository that never had a .env.example: generate one from your working .env in seconds
  • →Onboarding: new developers copy it to .env and see exactly which keys to fill in
  • →After adding a variable: regenerate and commit so the template stays in sync
  • →Open-source projects that need to document configuration without leaking anything

Common mistakes

  • ⚠Secrets in comments: a line like # old key sk_live_… is kept as a comment. Read the output once before committing
  • ⚠Generating the file but forgetting to commit it, or committing .env by accident. Check git status first
  • ⚠Leaving keys without context: add a short comment above anything that is not obvious (# from Stripe Dashboard > Developers > API keys)
  • ⚠Letting it drift: when the app needs a new key, the example has to change in the same commit

What a good .env.example looks like

A .env.example (also called .env.sample or .env.template) lists every variable the app reads, with no real values. A new developer runs cp .env.example .env, fills in the blanks and the app starts. The generator produces the skeleton; a few minutes of editing turns it into documentation:

.env.example
# ── App ─────────────────────────────
NODE_ENV=development
PORT=3000

# ── Database ────────────────────────
# Local: docker compose up db
DATABASE_URL=postgres://app:app@localhost:5432/app

# ── Auth ────────────────────────────
# Generate: openssl rand -base64 32
JWT_SECRET=

# ── Stripe (test mode keys only) ────
# Dashboard > Developers > API keys
STRIPE_SECRET_KEY=sk_test_
STRIPE_WEBHOOK_SECRET=whsec_
  • Group keys under comment headings in the order the app needs them.
  • Say where a value comes from: a dashboard path, a CLI command, or a teammate.
  • Local-only defaults are fine: a localhost database URL with dummy credentials helps more than an empty value.
  • Show the format with a prefix like sk_test_ or whsec_ so people paste the right key.

Keeping .env and .env.example in sync

Most "works on my machine" bugs come from a key that exists in one developer's .env but not in the template. Three ways to catch drift:

  1. Paste both files into the missing env detector to see keys that exist in one file but not the other.
  2. Use the ENV diff checker for a side-by-side view before a release.
  3. Fail CI when they differ, with a few lines of shell:
# keys used in .env but missing from .env.example
comm -23 <(grep -oE '^[A-Za-z_][A-Za-z0-9_]*' .env | sort -u) \
         <(grep -oE '^[A-Za-z_][A-Za-z0-9_]*' .env.example | sort -u)

Also make sure git can never pick up the real file. The guide how to hide .env from git covers .gitignore patterns and what to do if a secret was already committed.

.env.example vs .env.local vs .env.defaults

FileContainsCommit to git?
.env.exampleall keys, no secrets, maybe safe defaultsyes
.envreal values for this machineno
.env.localmachine-specific overrides (Next.js, Vite)no
.env.development / .env.productionnon-secret defaults per mode (Next.js, Vite)yes, if no secrets
.env.defaultsfallback values loaded by dotenv-defaultsyes

Frequently asked questions

Should .env.example be committed to git?

Yes. It documents which variables the app needs without exposing values. Commit it and update it whenever a key is added or removed.

Which values does the generator keep?

None by default except, with the option switched on, NODE_ENV, PORT, DEBUG, LOG_LEVEL, APP_ENV, RAILS_ENV, PYTHON_ENV and ENVIRONMENT. Everything else becomes KEY=.

Are comments and export prefixes preserved?

Yes. Full-line comments, inline comments, blank lines and export stay where they are. With sort switched on, only the key lines are kept and sorted alphabetically.

Can I put placeholder values in the example?

Yes, and it often helps: a format hint like sk_test_ or a local URL like postgres://app:app@localhost:5432/app is safe. Never put a real key in it, not even a test key that still works.

Is .env.example the same as .env.sample or .env.template?

Yes, they are naming conventions for the same thing. .env.example is the most common and is what Laravel, many Node.js starters and the dotenv docs use.

Related tools

Learn more

coming soon

Get notified when env syncing launches

We're building a tiny tool to keep .env files in sync across teammates and environments. Leave your email — no spam, just a single launch ping.

We use your address only for this launch email. You can ask us to delete it at any time. Privacy policy