A simple CLI tool to generate .env.sample files from existing .env files. This tool reads your .env file, preserves comments and empty lines, and creates a sample file with keys but without values.
- Preserves comments and empty lines from the original
.envfile. - Generates a clean
.env.samplewith keys set to empty values. - Handles encoding issues, permissions, and file existence gracefully.
- Built with Python and Typer for a smooth CLI experience.
You can install using one of the following methods:
- Using pipx:
pipx install generate-env-sample
- Using uv:
uv tool install generate-env-sample
- Run directly with pipx:
pipx run generate-env-sample
- Run directly with uvx:
uvx generate-env-sample
- Python 3.11 or higher
This project uses uv for management. To build the project, follow these steps:
-
Install
uvby following the uv documentation. -
Clone the repository:
git clone https://github.com/heshinth/generate-env-sample.git cd generate-env-sample -
Sync the project dependencies using uv sync:
uv sync
Run the tool from the command line:
generate-env-sample--file: Specify the.envfile to read from (default:.env)--sample: Specify the output.env.samplefile (default:.env.sample)
-
Generate
.env.samplefrom the default.env:generate-env-sample
-
Use a custom
.envfile:generate-env-sample --file myenv.env --sample myenv.sample
-
Get help:
generate-env-sample --help
Given a .env file like:
# Database configuration
DB_HOST=localhost
DB_PORT=5432
# API keys
API_KEY=your_secret_key
The generated .env.sample will be:
# Database configuration
DB_HOST=
DB_PORT=
# API keys
API_KEY=
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.