You know the bug: production fails, staging works, and an hour later you find REDIS_URL missing from .env.production.
The quick way to find it is diff .env.staging .env.production. The problem is that it prints your database password and API keys straight to the terminal, and from there into CI logs, screenshots and the pull request where you pasted it.
So I built envdiff: it compares env files and shows key names only. Values are compared in memory and never printed.
👉 https://github.com/Guihakka2/envdiff
Try it
No install needed:
npx @guihakka2/envdiff # compares every .env* file in this folder
npx @guihakka2/envdiff .env.staging .env.production
npx @guihakka2/envdiff --scan . # does .env.example cover every key the code reads?
envdiff .env.staging vs .env.production
Missing in .env.production:
- REDIS_URL
Different values (hidden):
~ DATABASE_URL
Possible real secrets in template files:
! .env.example: AWS_ACCESS_KEY_ID (line 3)
✗ Not in sync
You learn that DATABASE_URL differs. You never see what it is.
What it checks
- Missing, extra and changed keys across 2 or more files
- Real-looking secrets (AWS, GitHub, Stripe, OpenAI, JWT, private keys…) committed to
.env.exampleand other templates - A real
.envcommitted to git (fails) or missing from.gitignore(warns) - Typos, with "did you mean
DATABASE_URL?" -
--scan .: keys your code reads that no env file defines, and keys nobody uses. Works for Node, Python, Go, Ruby, PHP, Java, Rust, C# and docker-compose -
# @expire 2027-03-31above a key warns 30 days before a token expires
Zero dependencies, runs offline, sends nothing anywhere.
In CI
- uses: Guihakka2/envdiff@v1
with:
files: .env.example .env.ci
args: --keys-only --strict
Exit code 0 in sync, 1 differences, 2 usage error. On a big existing project, --baseline records today's problems so only new ones fail. Leaked secrets are never baselined.
For AI coding agents
envdiff --mcp runs it as an MCP server, so Claude Code, Codex, Cursor and friends can check your env files themselves before a deploy. They get key names and line numbers, never values.
claude mcp add envdiff -- npx -y @guihakka2/envdiff --mcp
Why not an existing tool?
dotenv-linter and dotenv-diff are good. envdiff focuses on two things: comparing several env files where no value can ever reach the output, and catching real secrets committed to template files.
Standalone binaries for Windows, macOS and Linux are on the releases page if you don't have Node.js.
Issues and feedback are very welcome. What's the worst .env mistake you've shipped?
Written with AI assistance and reviewed by the author.
Top comments (0)