env-sentinel is a lightweight CLI tool for validating .env files in Node.js projects using a simple, human-readable schema format.
It helps developers prevent runtime misconfigurations, especially in multi-environment projects or CI/CD pipelines. With zero dependencies and blazing-fast execution, env-sentinel offers a modern alternative to bloated validators or manual .env.example guessing games.
Whether you're working solo or managing a team, env-sentinel brings confidence, clarity, and automation to your environment variable workflows — without needing to write a line of custom validation logic.
- Zero-dependency .env file checker for Node.js projects.
- Validate your environment variables with a simple schema.
- Auto-generate schema from existing
.envfiles with type inference. - Perfect for CI/CD pipelines, local dev, and safer config handling.
- Simple schema format (e.g.
VAR_NAME=required:number) - Smart type detection when generating from
.env - Zero dependencies
- CLI-ready: Use in local dev or pipelines
- Initializes
.env-sentinelwith inferred rules - Fast fail with clear, colorized output
npx env-sentinel # no install needed (recommended)or install globally/local if preferred:
npm install -g env-sentinelnpx env-sentinel init- Auto-detects types like number, boolean
- Creates .env-sentinel in current directory
npx env-sentinel init --forcenpx env-sentinel init --env-file .env.localEach line represents a variable and its rule:
DB_HOST=required
DB_PORT=required|number
DEBUG=optional|boolean
NODE_ENV=optional|enum:development,production,test| Syntax | Description |
|---|---|
| required | Must be defined |
| optional | Can be missed |
| number | Must be a number |
| string | Can be anything |
| boolean | Must be true of false |
| min:value | Is greater than or equal to the specified minimum value; for strings, it checks the length, and for numbers, it checks the numerical value. |
| max:value | Is less than or equal to the specified maximum value; for strings, it checks the length, and for numbers, it checks the numerical value. |
| enum:foo,bar | Must match one of listed values |
npx env-sentinelDefaults:
- .env (env file)
- .env-sentinel (schema file)
npx env-sentinel check --env-file .env.production --schema config/prod.schemaOn success:
✅ Environment validation passed!
On failure:
🛑 Missing required variable: DB_HOST
⚠️ Insecure value detected: DB_PASS=1234
- No runtime bloat — stays lightweight and fast
- More transparent than Joi/Zod configs
- Quick to set up and CI-friendly
- Fits modern DX (type-safe, CLI-ready, focused)
- Custom rule plugins
- GitHub Action integration
- VSCode extension
- .env.template generator from schema
- Dry run & suggestion mode
MIT — Free to use, modify, and contribute!