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:
bashcat .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:
bashheroku 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:
bashDATABASE_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.
Michael Thomson
Software developer building Shopify apps, AI tools, and ecommerce systems.
Get in touch