CLI tool that compares .env files across branches, environments, or commits.
- Diff: Compare
.envfiles between two sources (branches, commits, local files) - Check: Detect missing variables relative to a baseline (
.env.example) - Audit: Flag suspicious values (plaintext passwords,
localhostin production, empty secrets, weak defaults) - Integrations: Parse Docker Compose, Vercel, Railway configs
- Multiple formats: Output as plain text, JSON, or Markdown
git clone https://github.com/DevKaliper/env-diff-cli.git
cd env-diff-cli
npm install
npm run build
npm linkAfter installation, verify it works:
envdiff --helpRun the demo to see all features:
./demo.shenvdiff diff .env.development .env.production
envdiff diff main:.env HEAD:.env
envdiff diff .env compose:./docker-compose.ymlenvdiff check .env.production
envdiff check .env.production --baseline .env.exampleenvdiff audit .env.production
envdiff audit .env.production --severity errorCompare two environment sources.
Sources can be:
- File paths:
./apps/api/.env.production - Git refs:
main:.env,HEAD~1:.env - Integration handles:
compose:./docker-compose.yml,vercel:,railway:
Options:
--format <format>- Output format: text, json, or markdown (default: text)--only-missing- Show only added/removed variables--only-changed- Show only changed variables--no-values- Mask variable values in output
Validate environment file against a baseline.
Options:
--baseline <file>- Baseline file to compare against (default: .env.example)--only-missing- Show only missing variables
Detect suspicious values in environment file.
Options:
--severity <level>- Filter by severity: warn or error
SECRET_IN_PLAIN- Password/secret matches common weak patternsLOCALHOST_IN_PROD- Production variable containslocalhostor127.0.0.1EMPTY_SECRET- Secret variable is emptyWEAK_DEFAULT- Value is a common weak default (password,changeme, etc.)MISSING_REQUIRED- Variable present in baseline but absent in target
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm test:coverage
# Lint
npm run lint
# Format
npm run format
# Build
npm run build# Compare production and development
envdiff diff .env.production .env.development
# Check if all required vars are set
envdiff check .env.production
# Find security issues
envdiff audit .env.production --severity error
# Compare current branch with main
envdiff diff main:.env HEAD:.env --format markdown
# Compare local file with Docker Compose
envdiff diff .env compose:./docker-compose.yml --no-valuesMIT