Skip to content
Tools & UtilitiesFree

Env Validator CLI

Validate required environment variables locally, in CI, and before production builds so missing secrets fail early.

Prerequisites

  • A Node.js project with npm scripts.
  • A list of required environment variables for each environment.
  • CI or deployment scripts where validation can run before build.
1

Install the CLI

Setup snippet
npm install -D @codersarts/env-validator
2

Create an environment schema

Setup snippet
{
  "DATABASE_URL": { "required": true, "type": "url" },
  "STRIPE_SECRET_KEY": { "required": true, "startsWith": "sk_" },
  "APP_URL": { "required": true, "type": "url" }
}
3

Add npm scripts

Setup snippet
"scripts": {
  "env:check": "env-validator --schema env.schema.json --file .env",
  "prebuild": "npm run env:check"
}
4

Wire validation into CI

Checklist
  • Run validation before tests and production builds.
  • Use environment-specific schema files when staging and production differ.
  • Fail the pipeline when required secrets are empty or malformed.

Need help implementing this?

CodersArts can wire this into your existing stack, adapt the flow to your product, and hand over a working implementation.

Request implementation help