@sharoussh/env-validator
v1.0.1
Published
CLI tool to validate and lint .env files
Maintainers
Readme
env-validator
Zero-dependency CLI to validate and lint .env files. Catches common mistakes before they break your app.
Install
npm install -g env-validatorOr run without installing:
npx env-validatorUsage
# validate .env in current directory
env-validator
# validate a specific file
env-validator .env.production
# validate multiple files
env-validator .env .env.staging
# only show errors, hide warnings
env-validator --quietWhat it checks
| Check | Severity |
|-------|----------|
| Missing = sign | error |
| Empty key | error |
| Invalid characters in key (-, spaces, etc.) | error |
| Key starts with a number | error |
| Unmatched quotes in value | error |
| Lowercase key (should be UPPER_CASE) | warning |
| Empty value | warning |
| Duplicate key | warning |
| Unquoted value with spaces | warning |
| Inline comment missing space before # | warning |
Example output
Validating .env
18 lines · 5 keys
✗ line 3 [error] Missing '=' — not a valid KEY=VALUE pair
⚠ line 7 [warn ] Key "db_host" should be UPPER_CASE
✗ line 12 [error] Key "NAME" has unmatched quotes in value
⚠ line 15 [warn ] Duplicate key "PORT" (first seen on line 4)
2 error(s) 2 warning(s)Options
| Flag | Description |
|------|-------------|
| --quiet | Only show errors, suppress warnings |
| --no-color | Disable colored output (good for CI logs) |
| --help | Show help |
Exit codes
0— no errors (warnings don't affect exit code)1— one or more errors found
This makes it easy to use in CI pipelines:
# GitHub Actions example
- run: npx env-validator .env.exampleRunning tests
npm testLicense
MIT
