Skip to main content

Generate example .env files from existing .env files with placeholder detection.

Project description

Envertor 🔍

PyPI version Python License: MIT

Envertor is a CLI tool that generates .env.example files by extracting environment variables from existing .env files or by scanning Python and JavaScript/TypeScript projects. It also helps keep your secrets safe with automatic .gitignore protection and CI/CD-ready parity checks.

Install

pip install envertor

Development install:

pip install -e .

Usage

Generate .env.example from an existing .env

Strips real values and replaces them with type-appropriate placeholders:

envertor -i .env -o .env.example
Original .env Generated .env.example
SECRET=mysecret SECRET=
PORT=8080 PORT=
DEBUG=true DEBUG=
RATE=3.14 RATE=

Use --placeholder to write type-aware values instead of empty:

envertor -i .env -o .env.example --placeholder
Original .env With --placeholder
SECRET=mysecret SECRET=''
PORT=8080 PORT=0
DEBUG=true DEBUG=false
RATE=3.14 RATE=0.0

Scan a project for environment variables

Detects env vars used in source code and generates .env.example from actual usage — no existing .env required:

envertor -p ./my-project -o .env.example

Limit scanning to a specific language:

envertor -p ./my-project --lang python
envertor -p ./my-project --lang js

Supports:

  • Python: os.getenv("VAR"), os.environ["VAR"], os.environ.get("VAR")
  • JS/TS: process.env.VAR (.js, .ts, .jsx, .tsx)

Create .env from .env.example

Bootstrap a local .env from the example file so teammates can fill in their own values:

envertor --create-env                        # reads .env.example by default
envertor --create-env staging.env.example    # reads a custom file

If .env already exists, writes .env.envertor instead to avoid overwriting.


Check parity between .env and .env.example

Explicitly verify that both files have the same keys. Designed for CI/CD pipelines — exits 1 on mismatch:

envertor --check
envertor --check --env-file /deploy/.env --example-file /repo/.env.example

Example output on failure:

[envertor] FAIL: Keys mismatch between .env and .env.example
  Missing from .env:          NEW_KEY
  Missing from .env.example:  OLD_KEY

Use in a pipeline:

# GitHub Actions example
- name: Check env parity
  run: envertor --check --env-file .env --example-file .env.example

Show version

envertor -v

Automatic safety checks

Every time envertor runs, it performs these checks automatically:

.gitignore protection — ensures .env is listed in .gitignore. Creates the file if it doesn't exist:

[envertor] Created .gitignore with .env
[envertor] Added .env to .gitignore

Key parity warning — warns if .env and .env.example have different keys:

[envertor] WARNING: Keys in .env not documented in .env.example: DB_URL
[envertor] WARNING: Keys in .env.example not found in .env: NEW_KEY

Leftover values warning — warns if .env.example contains non-placeholder values (real secrets accidentally left behind):

[envertor] WARNING: .env.example has a real value set for API_KEY

Options

Flag Description
-i, --input FILE Path to input .env file
-o, --output FILE Path to output .env.example (default: .env.example)
-p, --project DIR Project folder to scan for env variable usage
--lang python|js|both Language filter for project scanning (default: both)
--placeholder Use type-aware placeholders (0, 0.0, false, '') instead of empty values
--create-env [FILE] Create .env from FILE (default: .env.example)
--check Check key parity and exit 1 on mismatch (CI/CD mode)
--env-file FILE .env path for --check (default: .env)
--example-file FILE .env.example path for --check (default: .env.example)
-v, --version Show version

Notes

  • Automatically skips node_modules/, venv/, __pycache__/, .next/, .git/, .idea/, .vscode/
  • Regex-based scanning catches the most common patterns (os.getenv, os.environ, process.env)
  • .env.envertor is a safe backup — rename it to .env or diff it against your existing one

License

MIT © Samin Yeasar

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envertor-0.1.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envertor-0.1.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file envertor-0.1.2.tar.gz.

File metadata

  • Download URL: envertor-0.1.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.3

File hashes

Hashes for envertor-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fb7ed1de58bd6b8f224c1ab60269fa0169f2ef849a3697d5064b08bdae17f022
MD5 d5ed5fc0bc66a38af920e74e55957de1
BLAKE2b-256 f35945ddba691429b14ba46b29d5cbf0e61a1696060e091596b605011fdca86b

See more details on using hashes here.

File details

Details for the file envertor-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: envertor-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.3

File hashes

Hashes for envertor-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e986adc0ee23c82b6fd9b3eed0a9135d9f02d59b67b24f46ef07800e5018e351
MD5 b910e5f6eaefe21696d45dc68a28eec1
BLAKE2b-256 af983b8b2a805366cc7158cd7e73219e2711df72d80322b16124d1274e1bfdc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page