---
title: "Managing environment variables from your terminal with Netlify CLI"
description: "Keep sensitive variables in a safe place with environment variables. Learn how you can keep your environment variables coordinated with the Netlify CLI."
source: "https://www.netlify.com/blog/2021/07/12/managing-environment-variables-from-your-terminal-with-netlify-cli/"
last_updated: "2026-07-10T19:13:05.000Z"
---
When you need to keep a sensitive variable in a safe place, environment variables can help. And with Netlify you can manage your environment variables centrally in your site’s deploy settings admin, and event access them in your local build if your run your site with `netlify dev`.

[Tara](https://www.netlify.com/blog/authors/tara-z.-manicsic/?utm_campaign=devex-ph&utm_source=blog&utm_medium=social&utm_content=cli-env-vars) gave a great explanation [in this post](https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/?utm_campaign=devex-ph&utm_source=blog&utm_medium=social&utm_content=cli-env-vars) recently. You should check that out!

Until recently, I would make environment variables available to my local development build by including a `.env` and then using a package like [dotenv](https://www.npmjs.com/package/dotenv) to make the values stashed in the `.env` file available to my code with `process.env.MY_ENVIRONMENT_VARIABLE`. that worked fine, but as Tara noted, you need to take care not to commit your `.env` file, and you need to manually record your variables locally to match those you’ve stored in Netlify. We can do better.

This is old news, Phil. We learned this already from [Tara’s post](https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/?utm_campaign=devex-ph&utm_source=blog&utm_medium=social&utm_content=cli-env-vars). True. But there’s one more thing…

Not only can you use the [Netlify CLI](https://github.com/netlify/cli) to access your centrally managed environment variables when you run your build with `netlify dev`, but you can also use the CLI to create and manage those environment variables directly from your terminal. Here’s how:

## First, you need a site

To get started you need to have the [Netlify CLI](https://github.com/netlify/cli) installed, and be working in a site that Netlify manages for you.

```
# Install Netlify CLInpm i -g netlify-cli
# Create a new site on Netlify from your local development foldernetlify init
# Or, if you want to work with an existing site, make sure you have# linked your local dev version to site on Netlifynetlify link
```

With a site managed by Netlify you can now add and edit your environment variables like this:

### Add an environment variable

```
netlify env:set MY_ENV_VAR "The value of my environment variable"
```

### Update an environment variable

```
netlify env:set MY_ENV_VAR "The updated value of my environment variable"
```

### Remove an environment variable

```
netlify env:unset MY_OLD_ENV_VAR
```

When you run these commands locally you are making authenticated calls to Netlify to manage those centrally stored environment variables, so you can create, manage, and consume them in your local and your production builds all without leaving your terminal. Handy!

Some folks may prefer the more visual approach to managing environment variables which is available from the Netlify admin UI. [Tara covered all of that here in her post](https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/?utm_campaign=devex-ph&utm_source=blog&utm_medium=social&utm_content=cli-env-vars). It’s nice to have choices!

## Wait, there’s more

If you’ve come this far, you may wish to explore the other options available through Netlify CLI. There is help provided for all the things you can do with environment variables by running `netlify env help`

A few more utilities that can be useful:

### List all the environment variables

```
netlify env:list
```

### List all the environment variable in JSON format

```
netlify env:list --json
```

### Import environment variables from a file

Perhaps you already have your environment variables stored in a local file like a `.env` file. You can use that as a source to bulk import into Netlify like this:

```
netlify env:import .env
```

## Environment variables shared across a team

Collaborating as part of a team on Netlify unlocks a number of advantages. One is having the ability centrally manage environment variables which all sites in that team can access and use. These variables are visible to you as a member of a team just the same as other variables. But they do need to be managed via the admin UI. You can lean more about [managing environment variables in the docs](https://docs.netlify.com/configure-builds/environment-variables/?utm_campaign=devex-ph&utm_source=blog&utm_medium=social&utm_content=cli-env-vars#declare-variables).

## Explore the CLI

There is a lot that Netlify CLI can do to help you be more productive when creating and managing your sites. A good place to look for more tips is in the help provided by the CLI itself. I’d recommend digging around:

```
# Overview of commands availablenetlify help
# More specific help for a given commandnetlify help [command]
```

You can also explore [the code repository for the Netlify CLI on GitHub](https://github.com/netlify/cli).

Happy CLI-ing!

### Share

-   [X (fka Twitter)](https://twitter.com/intent/tweet?text=Managing environment variables from your terminal with Netlify CLI&url=https://www.netlify.com/blog/2021/07/12/managing-environment-variables-from-your-terminal-with-netlify-cli//)
-   [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.netlify.com%2Fblog%2F2021%2F07%2F12%2Fmanaging-environment-variables-from-your-terminal-with-netlify-cli%2F%2F)
-   [Facebook](https://www.facebook.com/sharer.php?u=https://www.netlify.com/blog/2021/07/12/managing-environment-variables-from-your-terminal-with-netlify-cli//)
-   [Bluesky](https://bsky.app/intent/compose?text=Managing environment variables from your terminal with Netlify CLI+https://www.netlify.com/blog/2021/07/12/managing-environment-variables-from-your-terminal-with-netlify-cli//)

* * *

### Tags

-   [Tips](/blog/tags/tips/)
-   [CLI](/blog/tags/cli/)
-   [Build](/blog/tags/Build/)

## Keep reading

![](/images/blog-fallback-thumbnail.svg)

Guides & Tutorials May 19, 2020

[

### Environment variables and preview deploys get a boost

](/blog/2020/05/19/environment-variables-and-preview-deploys-get-a-boost/)

-   ![Profile picture of Phil Hawksworth](/_astro/9cfe2bbe94bcb555ce3ac7683ac7905ad3fd32b1-400x400_Z18H6R1.webp)
    
    Phil Hawksworth
    

![](/images/blog-fallback-thumbnail.svg)

Tools & Services July 5, 2021

[

### Easy Access Environment Variables

](/blog/2021/07/05/easy-access-environment-variables)

-   ![Profile picture of Tara Z. Manicsic](/_astro/2ac74d0595066130d59f8c97e61332017cdbcb94-1000x921_ZyTafG.webp)
    
    Tara Z. Manicsic
    

## Recent posts

News & Announcements June 25, 2026

[

### Netlify Functions, designed for Agent Experience

](/blog/netlify-functions-designed-for-agent-experience)

-   ![Profile picture of Eduardo Bouças](/_astro/52958f21e8450baf6d8e60302341a984e220c0cd-512x512_13VDlu.webp)
    
    Eduardo Bouças
    

News & Announcements June 24, 2026

[

### How we measure Netlify’s Agent Experience

](/blog/how-we-measure-netlify-agent-experience)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

Guides & Tutorials May 15, 2026

[

### How to build a real-time AI chatbot in minutes with Netlify Agent Runners (no backend)

](/blog/how-to-build-a-real-time-ai-chatbot-in-minutes-with-netlify-agent-runners-no-backend)

-   ![Profile picture of Nahrin Jalal](/_astro/f0e7c8f227a03fe58340c99ef5439d5a896c0733-272x272_Z23kDpD.webp)
    
    Nahrin Jalal
    

![](/_astro/3f255b372fa958df35802666ee33b4609b2d71bd-1200x1586_1VtE2D.webp)

### How do the best dev and marketing teams work together?

[Access the report](https://www.netlify.com/reports/2024-leadership-trend-report/access/)