Bulk import environment variables from .env

For teams on the new environment variables experience—which is most of you at time of writing!—you can now bulk import environment variables from an .env on the Netlify UI. Bulk import is still available on the Netlify CLI as well.

Bulk import variables to Netlify

Choose “Import from a .env file” on Site Settings > Environment Variables or Team Settings > Environment Variables:

Paste in your .env contents (KEY=value format), and choose which scopes and deploy contexts you’d like these values available to:

You can then choose how to handle any conflicts:

Moving variables from site to site

We recently added the ability to export environment variables from a site in .env format. With both exporting and importing available, you can copy variables from site to site more easily.

These exports include comments that specify which deploy context and/or scope you exported:

# Site environment variables for your-site
# Context: production
# Scope: builds
# Date: 12/16/2022, 12:00:00 AM

If you included this code comment in the “Contents of .env file” field when importing, we will automatically set the imported variables to the builds scope and production deploy context:

Have some variables that you need across all sites for the foreseeable future? Teams on Pro plans and above also have the option to set shared environment variables once for all their sites at Team Settings > Environment Variables.

Let us know what you think!

We hope this makes working with variables at scale a little easier. Please let us know what you think here in the forums!

2 Likes