@kszongic/dotenv-gen-cli
v1.0.0
Published
Generate .env files from .env.example templates with defaults and interactive prompts
Maintainers
Readme
@kszongic/dotenv-gen-cli
Generate .env files from .env.example templates — interactively or with defaults.
Install
npm i -g @kszongic/dotenv-gen-cliUsage
# Interactive mode — prompts for each variable
dotenv-gen
# Use default values without prompting
dotenv-gen -d
# Custom template and output
dotenv-gen .env.production -o .env.prod
# Strip comments, overwrite existing
dotenv-gen --strip --forceHow It Works
Given a .env.example like:
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp
# Auth
JWT_SECRET=
API_KEY=changemeRunning dotenv-gen will prompt you for each value (showing defaults), then write .env.
Running dotenv-gen -d copies defaults as-is — great for CI/CD or quick setup.
Options
| Flag | Description |
|------|-------------|
| -o, --output <file> | Output file (default: .env) |
| -f, --force | Overwrite existing output |
| -d, --defaults | Use defaults without prompting |
| -s, --strip | Remove comments from output |
| -h, --help | Show help |
| -v, --version | Show version |
Why?
Every project has .env.example. Setting up .env manually is tedious and error-prone. This tool makes it a one-command operation.
License
MIT © 2026 kszongic
