dotenv-validator-cli
v1.0.0
Published
CLI tool to sync and validate .env files against .env.example — detect missing, extra, or mismatched environment variables
Downloads
121
Maintainers
Readme
env-sync
CLI tool to sync and validate .env files — detect missing, extra, or mismatched environment variables between .env.example and .env.
Why?
Every project with environment variables has the same problem:
- You add a new config to
.env.examplebut forget to update.env - Someone deploys without the right env vars set
- You waste hours debugging "undefined is not a function" when it's really
DATABASE_URLmissing
env-sync catches these before they cause issues.
Install
# Install globally
npm install -g env-sync
# Or use directly with npx (no install needed)
npx env-syncUsage
Basic comparison
env-syncCompares .env.example with .env in current directory — shows missing keys.
Auto-fix missing keys
env-sync --fixAdds all missing keys from .env.example into .env with empty values.
Strict mode (flag extra keys too)
env-sync --strictAlso shows keys in .env that aren't in .env.example.
JSON output (for CI/scripts)
env-sync --jsonOutputs machine-readable JSON. Exit code 0 = no issues, 1 = issues found.
Initialize .env.example from .env
env-sync --initCreates .env.example from your current .env (keys only, no values).
Custom file paths
env-sync --example .env.dev.example --env .env.productionUse in CI (GitHub Actions)
- name: Validate env files
run: npx env-sync --strict --jsonAPI
const { validate } = require('env-sync');
const result = validate({
example: '.env.example',
env: '.env',
strict: true,
});
// { missing: [...], extra: [...], status: 'ok'|'issues' }License
MIT
