Compare two .env files. Shows missing keys, extra keys, and value differences. Essential for staging vs production env validation.
Author: Jose Zuma
git clone https://github.com/josezuma/env-diff.git
cd env-diff
python3 scripts/diff.py .env.staging .env.prod$ python3 scripts/diff.py .env.staging .env.prod
📋 .env Comparison: .env.staging vs .env.prod
🔴 Only in .env.staging:
DEBUG=true
🟢 Only in .env.prod:
SECRET_KEY=supersecret
🟡 Different values (2):
API_KEY
.env.staging: abc123
.env.prod: xyz789
DB_HOST
.env.staging: localhost
.env.prod: prod.example.com
📊 Summary:
Total keys: .env.staging: 4 | .env.prod: 4
In common: 3
Different: 2
Missing: 1 in .env.prod | 1 in .env.staging| Feature | Description |
|---|---|
| Missing keys | Keys in file1 but not in file2 (marked 🔴) |
| Extra keys | Keys in file2 but not in file1 (marked 🟢) |
| Value diff | Same key, different values (marked 🟡) |
| Summary | Total counts, common, different, missing |
| JSON output | Machine-readable with --json |
| No deps | Python stdlib only |
.env drift between environments causes bugs. This catches missing config before they reach production.
MIT © 2026 Jose Zuma