# Import environment variables using the Postman VS Code extension
You can [import `.env` files with environment variables](#import-environment-variables) from your API project into new environments in Postman. Then you can [sync changes](#sync-environment-variables) from your `.env` files to their respective environments in Postman. This enables you to maintain your environment variables in your API project and sync them with your environments in Postman when you're ready to test your APIs.
## Import environment variables
When you open your API project in VS Code, you'll be notified by an in-app notification if the Postman VS Code extension detects new `.env` files. You can bulk [import multiple `.env` files](#import-multiple-env-files) and their environment variables into Postman. You can also [import a single `.env` file](#import-a-single-env-file) with its environment variables by clicking the link at the top of the file or right-clicking the file.
From the imported files in your API project, you can then [open the environment variables](#work-with-imported-env-files) in their respective environments in Postman.
Before importing your files, make sure your project has at least one file with the `.env` extension that stores your project's environment variables in key-value pairs.
### Import multiple .env files
To bulk import multiple `.env` files, do the following:
1. Open your API project in VS Code. The Postman VS Code extension checks your API project for `.env` files you haven't imported into Postman.
2. In the in-app notification, click **Import Now**. You can also click
**Import** at the top of the sidebar, then select **.env files** to check for files.
3. In the **Import Environments** tab, review the detected `.env` files. You can enter text in the **Search by name** box to filter the list of files by name.
4. (Optional) Click **Edit** next to a `.env` file you want to edit before importing into Postman. You can take the following actions:
* Review the variables that import into Postman.
* Enter text in the **Filter variables** box to filter the list of variables by name or value.
* Click the environment name and rename it.
* Clear the checkbox next to variables you want to make unavailable. You can select each checkbox after import to make them available again.
* Change the [variable type](/docs/sending-requests/variables/variables/).
* Persist one or all current values (local) to their initial values (shared), syncing them with the Postman cloud after import. To persist all values, click
in the top right of the environment, then select **Persist all**. To persist a value, hover over a variable, click
, then select **Persist**.
* Reset one or all current values (local) to reflect their initial values (shared). To reset all values, click
in the top right of the environment, then select **Reset all**. To reset a value, hover over a variable, click
, then select **Reset**.
* Hover over a variable you don't want to import, then click
.
* Click **Reset** to revert all of your changes.
* When you're finished editing, click **Done**.
5. Select the checkbox next to one or more `.env` files you want to import into new environments in Postman. Each `.env` file is imported into its own environment in Postman.
6. Click **Import**.
As you make changes to your imported `.env` files in your project, you can [sync your changes with Postman](#sync-environment-variables).
### Import a single .env file
To import a single `.env` file, do the following:
1. Open your API project in VS Code.
2. Open the `.env` file you want to import, then click **Import to Postman** at the top of the file. You can also right-click the `.env` file, then click **Import / Open in Postman**.
You won't have the option to edit the environment variables before importing the `.env` file into Postman. You can edit the variables once they're imported, such as changing the variable type.
3. A new Postman environment opens in a new tab with the variables imported from your project. Review the imported variables.
4. Click **Save** if you make any changes to the environment.
As you make changes to your imported `.env` files in your project, you can [sync your changes with Postman](#sync-environment-variables).
### Work with imported .env files
Once your `.env` files are imported into Postman, you can open an imported file in your API project and click **Open in Postman** at the top. You can also right-click an imported file and select **Import / Open in Postman**. This opens the environment in a new tab with the environment variables you imported earlier.
When the environment is moved to a new workspace in Postman, these options open the relocated environment if you have permission to access it.
Learn more about [managing environments](/docs/developer/vs-code-extension/manage-environments/) in the Postman VS Code extension.
## Sync environment variables
You can sync changes made to your imported `.env` files with their respective environments in Postman.
When you sync changes to imported `.env` files, both the current (local) and initial (shared) values are updated in their respective environments in Postman. The initial value is synced to the Postman cloud, sharing it with your team when you share the environment.
To detect and sync changes in `.env` files, do the following:
1. Open your API project in VS Code.
2. Edit `.env` files you've already imported into Postman.
3. Choose how you want to sync your changes:
* Open the file in your project or its respective environment in Postman. Then click **Sync Now** in the in-app notification.
* Open the file in your project and click **Sync to Postman** at the top of the file.
* Right-click the file and select **Sync to Postman**.
4. Repeat these steps for each imported `.env` file you've made changes to.