Compare .env files to find missing, extra, and different variables.
npm install -g env-compare-cli# Basic comparison
env-compare .env .env.example
# Show actual values in diff
env-compare .env .env.production --values
# JSON output (for scripting)
env-compare .env .env.staging --json
# Generate merged file to stdout
env-compare .env .env.example --sync
# CI usage (exits with code 1 if differences found)
env-compare .env.example .env || echo "Environment mismatch!"| Flag | Description |
|---|---|
--values |
Show actual values in the comparison |
--json |
Output results as JSON |
--sync |
Print a merged env output to stdout |
-V |
Show version |
-h |
Show help |
- 🔴 Missing — variables in file1 but not in file2
- 🟡 Extra — variables in file2 but not in file1
- 🔵 Different — same key, different value
0— files are identical1— differences found (CI-friendly)
MIT