Skip to content
Tools & UtilitiesFree

Env Validator CLI

A zero-dependency CLI tool that validates your .env files against a typed schema at build time. Catch missing or malformed environment variables before your deployment fails โ€” not after.

Node.jsCLI
Free

A zero-dependency CLI tool that validates your .env files against a typed schema at build time. Catch missing or malformed environment variables before your deployment fails โ€” not after.

Full source code included
README + Documentation
Lifetime access & updates
30-day email support
30-day money-back guarantee
4.8rating
1,900downloads
MIT License

Open for personal & commercial use

What is Env Validator CLI?

Broken deployments from missing environment variables are embarrassingly common. Your CI/CD pipeline passes, the deployment succeeds, and then your application crashes at startup because DATABASE_URL is undefined in production. Or worse โ€” it doesn't crash, it just silently uses the wrong value. Env Validator CLI fixes this at the source. You define a schema file that describes every environment variable your application needs โ€” its type, whether it's required, and optionally a format (URL, email, UUID, etc). Run env-validate before your build step and it exits non-zero with a clear error message if anything is missing or malformed. Zero dependencies โ€” it's a single JavaScript file that runs on Node.js 16+. Add it to your package.json scripts and forget about env-related deployment failures.

Everything in the package.

Schema Definition Format

A simple JSON or JavaScript schema file format to declare all your environment variables, their types, whether they're required, and optional format validators.

CLI Binary

The env-validate command โ€” run it with a path to your schema and env file. Returns 0 on success, 1 on failure with a human-readable error report.

Type Validation

Validates that string, number, boolean, and URL values are the correct type. Catches common mistakes like passing 'true' as a string when a boolean is expected.

Format Validators

Built-in format validators for URL, email, UUID, port number, and hex colour. Extensible with custom regex patterns for domain-specific formats.

CI/CD Integration Guide

README examples for GitHub Actions, Vercel build hooks, Railway, and Heroku. Add one line to your build command and never get burned by a missing env variable again.

Multi-Environment Support

Validate different env files for different environments โ€” .env.development, .env.staging, .env.production โ€” each against the same schema with environment-specific overrides.

Built for production, not demos.

Zero Dependencies

A single JavaScript file with no npm dependencies. Runs on Node.js 16+ with no install overhead. Fast to run โ€” typically under 50ms.

Clear Error Messages

When validation fails, the output tells you exactly which variable is missing or wrong, what type was expected, and what was received. No detective work required.

Non-Zero Exit Code on Failure

Returns exit code 1 on any validation failure. Your build tool, CI/CD pipeline, or npm script will automatically abort if env validation fails.

Optional Variable Support

Mark variables as optional with a default value. The validator won't fail if optional variables are absent โ€” and it'll confirm the default is being used.

Secret Redaction in Output

Variables marked as secret are redacted in the validator's output (shown as ****) โ€” safe to run in CI logs without leaking API keys.

Watch Mode

Run with --watch to re-validate whenever the .env file changes. Useful during local development when you're adding new variables.

Who is this for?

Developers, indie hackers, and product teams who want to skip the boilerplate and ship faster.

Any Node.js Project

Whether it's a Next.js app, an Express API, a CLI tool, or a monorepo โ€” any project that uses environment variables benefits from validation at build time.

Teams Onboarding New Developers

New developers forget to copy .env.example. Running env-validate on npm start means they get a clear list of every missing variable on first run โ€” not a cryptic runtime error 10 minutes later.

CI/CD Pipelines

Add it as the first step in your CI pipeline. If environment variables aren't correctly set in your deployment environment, the build fails immediately and clearly.

Multi-Environment Deployments

Validate that staging and production have all required variables before deploying. Catch the classic 'works in staging, broken in production' env variable mismatch.

Technologies used.

Runtime

Node.js 16+

Dependencies

None (zero-dep)

Integration

npm scriptsGitHub ActionsVercelRailway

Formats

.env.env.local.env.productionJSON schema

Common questions.

Is this really free?

Yes โ€” completely free, MIT licensed. No email required, no account, no usage limits. Download it, use it in every project, and modify it however you want.

Does it work with dotenv?

Yes โ€” it reads standard .env files in the same format as dotenv. It's a validator, not a loader, so it complements dotenv rather than replacing it.

Can I use this with TypeScript projects?

Yes โ€” it validates .env files independent of your TypeScript setup. It doesn't generate TypeScript types, but if you want typed env access in TypeScript, the README suggests using it alongside t3-env or @t3-oss/env-nextjs.

What happens if a variable is present but an empty string?

By default, empty strings fail validation for required variables. You can explicitly allow empty strings per-variable in the schema if that's intentional.

Can I contribute or request features?

The source code is included in the download and on GitHub. PRs and feature requests are welcome โ€” file an issue and we'll review it.

Need something custom-built?

Need something more sophisticated โ€” a company-wide secrets management solution, environment variable syncing across services, or integration with Vault, AWS Secrets Manager, or Doppler? We build developer infrastructure tools and can scope a custom solution for your team's specific needs.

Ready to ship faster?

Get Env Validator CLI today and stop worrying about missing env variables โ€” for free.

Setup and implementation

Review prerequisites, installation steps, and configuration before integrating this product.

Read the setup documentation