Import environment variables using the Postman VS Code extension

You can import .env files with environment variables from your API project into new environments in Postman. Then you can regularly sync changes 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 and their environment variables into Postman. You can also import a single .env file with its environment variables by clicking the link at the top of the file or right-clicking the file.

Then from the imported files in your API project, you can open the environment variables in their respective environments in Postman.

Before importing your files, make sure your project has at least one file with the extension .env 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 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 icon Import at the top of the sidebar, and 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'd like 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 enter a new name.
    • 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 for a variable.
    • 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 Options icon in the top-right of the environment, then select Persist all. To persist one value, hover over a variable, click Options icon, then select Persist.
    • Reset one or all current values (local) to reflect their initial values (shared). To reset all values, click Options icon in the top-right of the environment, then select Reset all. To reset one value, hover over a variable, click Options icon, then select Reset.
    • Hover over a variable you don't want to import, then click Delete icon.
    • Click Reset to revert all of your changes.
    • When you're done editing, select Done.
  5. Select the checkbox next to one or more .env files you'd like 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.

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'd like to import, and click Import to Postman at the top of the file. You can also right-click the .env file, and 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 environment variables once they're imported, such as changing the variable type.

  3. A new Postman environment opens in a new tab with the environment variables imported from your project. Review the imported environment 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.

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.

Note that if the environment is moved to a new workspace in Postman, these options will open the relocated environment if you have permission to access it.

Learn more about managing 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'd like 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.

Last modified: 2025/07/25