Michael Thomson
PersonalMay 6, 20261 min read

Quickly Push Your .env Files to Heroku with One Command

Save time and avoid manual config entry—use this simple command to push your entire .env file to Heroku in seconds.

Quickly Push Your .env File to Heroku with One Command

If you've ever had to manually copy environment variables into Heroku, you already know how tedious (and error-prone) it can be.

Here's a quick command to push your plain .env file directly to Heroku:

bash
cat .env | xargs heroku config:set --app YOUR-APP-NAME

How it works cat .env reads your environment file xargs passes each variable into heroku config:set Heroku updates your app's config vars automatically How to use it Open your terminal Navigate to the directory containing your .env file Run the command above

Make sure you're logged into Heroku first:

bash
heroku login

And that's it. No manually pasting environment variables one by one into the dashboard.

Notes

This works best with simple .env files formatted like:

bash
DATABASE_URL=your_database_url
API_KEY=your_api_key
SECRET_TOKEN=your_secret_token

If your .env contains spaces, quotes, or multiline values, you may need a more robust approach.

Happy deploying.

Written by

Michael Thomson

Software developer building Shopify apps, AI tools, and ecommerce systems.

Get in touch