envpatch
v0.1.3
Published
CLI tool to validate, diff, and sync .env files against .env.example
Downloads
53
Maintainers
Readme
envpatch
Never deploy with a broken
.envagain — validate, diff, and sync environment files in one command.
Demo

$ 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 validFeatures
- 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
Getting Started
Prerequisites
- Node.js 18+
Install globally
npm install -g envpatchOr run without installing
npx envpatch checkUsage
# 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.exampleIn CI pipelines
# GitHub Actions — fail the build if .env is out of sync
- run: npx envpatch checkIn package.json scripts
{
"scripts": {
"env:check": "envpatch check",
"env:sync": "envpatch sync --dry-run",
"predev": "envpatch check"
}
}Stack
| | | |---|---| | Language | TypeScript 5 | | Runtime | Node.js 18+ | | CLI framework | Commander | | Output | Chalk |
Contributing
Pull requests are welcome. For major changes, open an issue first to discuss what you'd like to change.
License
Support
If envpatch saves you from a broken deploy, consider sponsoring on GitHub.
