Never deploy with a broken
.envagain — validate, diff, and sync environment files in one command.
$ envpatch check
✗ Missing keys (2):
- DATABASE_URL
- REDIS_URL
⚠ Empty values (1):
~ APP_KEY
3 issues found
$ envpatch sync
Added 2 keys to .env:
+ DATABASE_URL=
+ REDIS_URL=
$ envpatch check
✓ .env is valid
- Catch broken deploys early — spot missing keys before they cause production errors
- Visual diff — see exactly what's different between
.envand.env.exampleat a glance - One-command sync — copy missing keys from
.env.exampleto.envautomatically - Safe by default —
--dry-runpreviews all changes before writing anything - Custom paths — works with any naming convention (
--env,--exampleflags) - Zero config — drop it into any project, no setup required
- Node.js 18+
npm install -g envpatchnpx envpatch check# Create .env from .env.example (replaces: cp .env.example .env)
envpatch init
# Create with a custom output name
envpatch init --out .env.staging
# Check for missing or empty keys
envpatch check
# Show a visual diff
envpatch diff
# Add missing keys from .env.example to .env
envpatch sync
# Preview sync without writing
envpatch sync --dry-run
# Use custom file paths
envpatch check --env .env.staging --example .env.example
envpatch diff --env .env.staging --example .env.staging.example# GitHub Actions — fail the build if .env is out of sync
- run: npx envpatch check{
"scripts": {
"env:check": "envpatch check",
"env:sync": "envpatch sync --dry-run",
"predev": "envpatch check"
}
}| Language | TypeScript 5 |
| Runtime | Node.js 18+ |
| CLI framework | Commander |
| Output | Chalk |
Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.
If envpatch saves you from a broken deploy, consider sponsoring on GitHub.
