1 min read

How to import multiple environment variables to Vercel

Bulk import environment variables to a Vercel environment with a single CLI command.

Mar 23, 2022
Ryan Blunden Avatar
Ryan Blunden
Senior Developer Advocate
How to import multiple environment variables to Vercel
Back to the blog
How to import multiple environment variables to Vercel

Vercel's dashboard or CLI doesn't yet provide a solution for bulk uploading or adding multiple environment variables, but with the bash shell, jq, and Vercel CLI, we can make it happen!

It works by defining the environment variables in JSON format and using jq to transform the JSON into a vercel env add commands.

Install jq and the Vercel CLI:

Then link your Vercel application codebase locally by changing into the root directory of your application, then running:

Next, create the environment variables in JSON for a single environment (e.g.Development):

In your terminal, define which environment you'll be importing to:

Then run:

You'll see the sequential output from the Vercel CLI as each variable is added successfully.

Then delete the JSON environment variables file so any sensitive data is not left sitting unencrypted on your machine:

Then simply repeat for other environments!

Shameless plug

If you're reading this post, you clearly care about automation when it comes to managing application secrets and configuration.

As a Developer Advocate from Doppler, I'm a bit biased, but that's where the Doppler CLI and Doppler Vercel Integration can help with secret automation features such as a Git-style activity log with instant rollback support, automatic production redeploys when secrets change, and more.

Stay up to date with new platform releases and get to know the team of experts behind them.

Related Content

Explore More