Netlify CLI env command
env
Control environment variables for the current site
Usage
netlify env
Flags
filter
(string) - For monorepos, specify the name of the application to run the command indebug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging in
Subcommand | description |
---|---|
env:clone | Clone environment variables from one site to another |
env:get | Get resolved value of specified environment variable (includes netlify.toml) |
env:import | Import and set environment variables from .env file |
env:list | Lists resolved environment variables for site (includes netlify.toml) |
env:set | Set value of environment variable |
env:unset | Unset an environment variable which removes it from the UI |
Examples
netlify env:listnetlify env:get VAR_NAMEnetlify env:set VAR_NAME valuenetlify env:unset VAR_NAMEnetlify env:import fileNamenetlify env:clone --to <to-site-id>
env:clone
Clone environment variables from one site to another
Usage
netlify env:clone
Flags
filter
(string) - For monorepos, specify the name of the application to run the command inforce
(boolean) - Bypasses prompts & Force the command to run.from
(string) - Site ID (From)to
(string) - Site ID (To)debug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging in
Examples
netlify env:clone --to <to-site-id>netlify env:clone --to <to-site-id> --from <from-site-id>
env:get
Get resolved value of specified environment variable (includes netlify.toml)
Usage
netlify env:get
Arguments
- name - Environment variable name
Flags
context
(string) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) orbranch:your-branch
whereyour-branch
is the name of a branchfilter
(string) - For monorepos, specify the name of the application to run the command injson
(boolean) - Output environment variables as JSONdebug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging inscope
(builds | functions | post-processing | runtime | any) - Specify a scope
Examples
netlify env:get MY_VAR # get value for MY_VAR in dev contextnetlify env:get MY_VAR --context productionnetlify env:get MY_VAR --context branch:feat/make-it-pop # get value in the feat/make-it-pop branch context or branch-deploy contextnetlify env:get MY_VAR --scope functions
env:import
Import and set environment variables from .env file
Usage
netlify env:import
Arguments
- fileName - .env file to import
Flags
filter
(string) - For monorepos, specify the name of the application to run the command injson
(boolean) - Output environment variables as JSONreplace-existing
(boolean) - Replace all existing variables instead of merging them with the current onesdebug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging in
env:list
Lists resolved environment variables for site (includes netlify.toml)
Usage
netlify env:list
Flags
context
(string) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) orbranch:your-branch
whereyour-branch
is the name of a branch (default: all contexts)filter
(string) - For monorepos, specify the name of the application to run the command injson
(boolean) - Output environment variables as JSONscope
(builds | functions | post-processing | runtime | any) - Specify a scopedebug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging inplain
(boolean) - Output environment variables as plaintext
Examples
netlify env:list # list variables with values in the dev context and with any scopenetlify env:list --context productionnetlify env:list --context branch:feat/make-it-pop # list variables with values in the feat/make-it-pop branch context or branch-deploy contextnetlify env:list --scope functionsnetlify env:list --plain
env:set
Set value of environment variable
Usage
netlify env:set
Arguments
- key - Environment variable key
- value - Value to set to
Flags
context
(string) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) orbranch:your-branch
whereyour-branch
is the name of a branch (default: all contexts)filter
(string) - For monorepos, specify the name of the application to run the command inforce
(boolean) - Bypasses prompts & Force the command to run.json
(boolean) - Output environment variables as JSONsecret
(boolean) - Indicate whether the environment variable value can be read again.debug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging inscope
(builds | functions | post-processing | runtime) - Specify a scope (default: all scopes)
Examples
netlify env:set VAR_NAME value # set in all contexts and scopesnetlify env:set VAR_NAME value --context productionnetlify env:set VAR_NAME value --context production deploy-preview # set in the production and deploy-preview contextsnetlify env:set VAR_NAME value --context branch:feat/make-it-pop # set in the feat/make-it-pop branch contextnetlify env:set VAR_NAME value --context production --secretnetlify env:set VAR_NAME value --scope buildsnetlify env:set VAR_NAME value --scope builds functionsnetlify env:set VAR_NAME --secret # convert existing variable to secret
env:unset
Unset an environment variable which removes it from the UI
Usage
netlify env:unset
Arguments
- key - Environment variable key
Flags
context
(string) - Specify a deploy context for environment variables (”production”, ”deploy-preview”, ”branch-deploy”, ”dev”) orbranch:your-branch
whereyour-branch
is the name of a branch (default: all contexts)filter
(string) - For monorepos, specify the name of the application to run the command inforce
(boolean) - Bypasses prompts & Force the command to run.json
(boolean) - Output environment variables as JSONdebug
(boolean) - Print debugging informationauth
(string) - Netlify auth token - can be used to run this command without logging in
Examples
netlify env:unset VAR_NAME # unset in all contextsnetlify env:unset VAR_NAME --context productionnetlify env:unset VAR_NAME --context production deploy-previewnetlify env:unset VAR_NAME --context branch:feat/make-it-pop # unset in the feat/make-it-pop branch context