Logo

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
envnix generate

Options

The generate command supports various flags to customize its behavior:

OptionShorthandDescription
--input <file>-iCustom input file instead of the default .env
--output <file>-oCustom output file instead of the default .env.example
--all-aGenerate for all matched .env* files in the directory
--sort [asc|desc]Sort variables alphabetically (keeps comments attached)
--no-sortDisable sorting entirely
--force-fForce overwrite if the output file already exists
--dry-runPrint the result to stdout instead of writing to a file
--verbosePrint verbose logs for debugging
--quiet-qOnly output errors, suppressing standard messages
--checkCheck if the output matches an existing file (useful for CI environments)

Example Usages

Sort variables alphabetically in ascending order:

bash
envnix generate --sort asc

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
envnix generate --input .env --input .env.local

Generate examples for all environment files (.env, .env.local, .env.production):

bash
envnix generate --all

CI Validation (check if .env.example is up to date):

bash
envnix generate --check

How is this guide?

Last updated on August 2, 2026