Menu

.env File Generator

Build your .env and .env.example side-by-side. Mark secrets, get gh secret set commands, and paste the generated GitHub Actions YAML. No fake encryption — just correct configuration.

.env File Generator Studio GitHub Ready
Ready
Never commit .env with real values. Add .env to your .gitignore immediately. Only commit .env.example — it documents what variables are needed without exposing secrets .
How .env and GitHub Secrets Work Together

The Two-File Pattern

The .env convention separates configuration from code. The standard pattern is:

  • .env — your real local values. Never commit this. Add it to .gitignore [citation:1][citation:16].
  • .env.example — a template with the same variable names but blank or placeholder values. Commit this. It documents what the project needs [citation:1].

New team members copy .env.example to .env and fill in their own credentials. GitHub Actions uses a third channel: GitHub Secrets, which are injected as environment variables at runtime.

How GitHub Secrets Actually Work

GitHub Secrets are already encrypted. They use Libsodium sealed boxes, meaning the value is encrypted on your machine before it reaches GitHub's servers [citation:4][citation:11]. GitHub decrypts them only inside the workflow runner. You do not need to "obfuscate" them before storing — GitHub handles that.

What you actually need to do: (1) Store the secret in GitHub, (2) reference it in your workflow as ${{ secrets.NAME }}, (3) use it as an environment variable in your steps. The .env file is for local development only.

The gh secret set Command

GitHub CLI can bulk-upload secrets from a .env file with a single command [citation:2]:

gh secret set -f .env

Or set them one at a time:

gh secret set API_KEY --body "your-value"
gh secret set DATABASE_URL --body "postgres://..."

This tool generates the exact commands for your variables, so you can copy-paste them.

Referencing Secrets in a Workflow

Inside GitHub Actions, secrets are available via the secrets context [citation:9][citation:17]:

steps:
  - name: Deploy
    env:
      API_KEY: ${{ secrets.API_KEY }}
      DATABASE_URL: ${{ secrets.DATABASE_URL }}
    run: ./deploy.sh

The tool generates this YAML block for your specific variable names.

What This Tool Does Not Do

  • It does not encrypt your secrets. GitHub already does that. The tool only generates configuration files.
  • It does not upload anything. Your values stay in your browser. You run the gh commands yourself.
  • It does not replace .gitignore. You must add .env to .gitignore manually. This tool reminds you but cannot enforce it.

Frequently Asked Questions

Should I commit .env?
Never. Commit .env.example with blank values. Add .env to .gitignore. This is the standard twelve-factor pattern [citation:1][citation:16].
Do I need to obfuscate secrets before storing them in GitHub?
No. GitHub Secrets are already encrypted with Libsodium sealed boxes before they leave your machine [citation:4][citation:11]. Double-encrypting them would break your workflows.
What does gh secret set -f .env do?
It reads each line of the .env file and creates a GitHub Secret for every KEY=value pair. It's the fastest way to bulk-upload secrets [citation:2].
How do I reference a secret in a workflow?
Use ${{ secrets.MY_SECRET }} in your YAML. Assign it to an env: variable or pass it as an input: to an action [citation:9][citation:17].
Why can't I use secrets in if: conditions?
GitHub does not allow direct secrets references in if: expressions. Set the secret as a job-level environment variable first, then reference that variable [citation:9].
Are secrets passed to forked repository workflows?
No. With the exception of GITHUB_TOKEN, secrets are not passed to workflows triggered from forked repositories [citation:9][citation:17].
Is my data uploaded to your server?
No. Everything runs in your browser. Your values never leave your device.
Can I use this for GitLab or Bitbucket?
The .env and .env.example files are platform-agnostic. Only the gh secret set commands and YAML snippet are GitHub-specific.

Related Tools