zorath-env
Package: zorath-env | Binary: zenv
Built by Zorath -- infrastructure for builders.
A tiny, fast CLI that makes .env sane.
zenv validates environment variables from a schema, generates docs, and helps keep config consistent across dev/staging/prod.
Why
.env files drift. Teams copy/paste secrets. CI fails late. Docs go stale.
zenv makes your schema the source of truth.
Schema is the source of truth. Docs and examples should be generated from it.
Privacy
zenv runs locally. No uploads, no secrets fetching, no phoning home.
Works with any stack
zenv is language-agnostic. Use it with Node.js, Python, Go, Ruby, Rust, Java, PHP, or any project that uses .env files. It's a standalone binary with zero runtime dependencies.
Install
Via cargo (recommended)
From source
Run locally
Quick start
- Create a schema:
- Validate your
.env:
- Generate docs:
Commands
zenv check
Validates .env against env.schema.json.
- exits
0if valid - exits
1if invalid (CI-friendly)
Secret Detection (--detect-secrets):
Scans for potential secrets that shouldn't be committed:
- AWS Access Keys and Secret Keys
- Stripe, GitHub, GitLab, Slack tokens
- Private key headers (RSA, SSH, PGP)
- JWT tokens
- URLs with embedded passwords
- High-entropy strings
zenv docs
Generates documentation for all env vars in the schema.
zenv init
Creates env.schema.json from .env.example (best-effort inference, you refine types after).
zenv version
Shows installed version and optionally checks for updates.
zenv completions
Generates shell completions for bash, zsh, fish, and PowerShell.
# Or evaluate directly
zenv example
Generates .env.example from schema (reverse of init).
zenv diff
Compares two .env files and shows differences.
Shows:
- Variables only in first file
- Variables only in second file
- Variables with different values
- Optional schema compliance check for both files
Files
By default, zenv looks for:
.env(optional).env.example(optional)env.schema.json(preferred)
Env file fallback
If .env doesn't exist, zenv check will automatically try:
.env.local.env.development.env.development.local
This is useful for Next.js and other frameworks that use .env.local for secrets.
You can override paths:
Schema format (v0.2)
env.schema.json is a JSON object where each key is an env var name.
Example:
Supported types:
stringintfloatboolurlenum
Validation rules
Add constraints with the validate field:
Schema inheritance
Schemas can extend other schemas:
Inheritance supports up to 10 levels of depth. Circular references are detected and will cause an error.
Remote schemas
Fetch schemas from HTTPS URLs for shared team configurations:
# Validate against remote schema
# Generate docs from remote schema
# Force fresh fetch (skip cache)
Features:
- HTTPS only (HTTP rejected for security)
- Automatic caching with 1-hour TTL
--no-cacheflag to bypass cache- Remote schemas can extend other schemas (URLs resolved relative to parent)
.env features
Comments and Blank Lines
Full-line comments, inline comments, and blank lines are supported:
# This is a full-line comment
DATABASE_URL=postgres://localhost/db # inline comment
# Blank lines are ignored
PORT=3000
Export prefix
Shell-style export prefix is supported for compatibility:
export DATABASE_URL=postgres://localhost/db
export NODE_ENV=development
Variable interpolation
Reference other variables with ${VAR} or $VAR:
BASE_URL=https://api.example.com
API_ENDPOINT=${BASE_URL}/v2
Multiline values
Use quoted strings for multiline:
SSH_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA...
-----END RSA PRIVATE KEY-----"
Escape sequences
Double-quoted strings support \n, \t, \r, \\, \"
Example output
Success
Validation errors
)
When unknown variables are found in your .env that are not in the schema, zenv will show a helpful tip suggesting you update your schema.
Pre-commit hook
# .git/hooks/pre-commit (make executable)
#!/usr/bin/env bash
if [; then
if ; then
||
else
||
fi
fi
GitHub Action
Validate .env files in your CI/CD pipeline:
- name: Validate .env
uses: zorl-engine/zorath-env/.github/actions/zenv-action@main
with:
schema: env.schema.json
env-file: .env.example
Inputs:
schema- Path to schema file (default:env.schema.json)env-file- Path to .env file (default:.env)allow-missing-env- Allow missing .env (default:true)version- zenv version to use (default:latest)
Outputs:
valid-trueif validation passederrors- JSON array of error messages
Connect
- Official site: zorl.cloud
- Documentation: zorl.cloud/zenv/docs
- GitHub: github.com/zorl-engine/zorath-env
- crates.io: crates.io/crates/zorath-env
- All links: edgeurl.io/p/zorl-engine
License
MIT