Generate
How to generate .env.example files.
Generating .env.example
By default, the generate command reads your .env file and generates a sanitized .env.example file.
bash
Options
The generate command supports various flags to customize its behavior:
| Option | Shorthand | Description |
|---|---|---|
--input <file> | -i | Custom input file instead of the default .env |
--output <file> | -o | Custom output file instead of the default .env.example |
--all | -a | Generate for all matched .env* files in the directory |
--sort [asc|desc] | Sort variables alphabetically (keeps comments attached) | |
--no-sort | Disable sorting entirely | |
--force | -f | Force overwrite if the output file already exists |
--dry-run | Print the result to stdout instead of writing to a file | |
--verbose | Print verbose logs for debugging | |
--quiet | -q | Only output errors, suppressing standard messages |
--check | Check if the output matches an existing file (useful for CI environments) |
Example Usages
Sort variables alphabetically in ascending order:
bash
Multiple Input Files:
You can specify multiple input files. ENVNIX will automatically resolve the output names (e.g. .env.local becomes .env.local.example).
bash
Generate examples for all environment files (.env, .env.local, .env.production):
bash
CI Validation (check if .env.example is up to date):
bash
How is this guide?
Last updated on August 2, 2026