# 10 Tips for Working with Postman Variables

---

 This is a follow-up to our popular post about [introducing variables in Postman](https://blog.postman.com/using-variables-inside-postman-and-collection-runner/).---

 [Variables](https://learning.postman.com/docs/sending-requests/variables/) are a fundamental concept in programming, and in [Postman](https://www.postman.com/), they can be your best friend. Instead of painstakingly updating individual values, use variables to cascade changes effortlessly through the rest of your code. If you’re not already using variables in Postman, get ready to have your mind blown.![screen](https://voyager.postman.com/gif/tim-and-eric-mind-blown.gif)

 With Postman variables, you can: - Reuse values so you can keep your code DRY (Don’t Repeat Yourself)
- Configure your setup to accommodate different users or [environments](https://learning.postman.com/docs/sending-requests/managing-environments/)
- Extract data from responses and [chain together requests](https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/) in a collection
- And more!
 
### **10 tips for working with Postman variables**

1. 1. 1. **Use variables in the request builder:** Use [variables in the request builder](https://learning.postman.com/docs/sending-requests/variables/) anywhere text is used, such as the URL, URL parameters, headers, authorization, request body, and header presets. Postman uses string substitution to replace variable names enclosed in double curly braces - like `{{variableName}}` with its corresponding value as a global, collection, or environment variable. For example, you can store access credentials or endpoint paths as variables. In this way, you can easily configure your setup to accommodate different users or server environments. [![gif](https://blog.postman.com/wp-content/uploads/2017/12/image3-1.png)](https://blog.postman.com/wp-content/uploads/2017/12/image3-1.png)
        2. **Dynamic variables:** Generate and use [dynamic variables](https://learning.postman.com/docs/sending-requests/variables/) in the request builder as unique IDs, timestamps, or random integers. Use dynamic variables with the double curly braces syntax—like `{{$timestamp}}`—in the request URL / headers / body.[![screen](https://blog.postman.com/wp-content/uploads/2017/12/image11.png)](https://blog.postman.com/wp-content/uploads/2017/12/image11.png)
        3. **Autocomplete for variables:** Type an open curly brace in the request builder (or type the first letter of the variable in the script sections) to bring up the [autocomplete menu](https://learning.postman.com/docs/sending-requests/variables/).[![screen](https://blog.postman.com/wp-content/uploads/2017/12/image9.png)](https://blog.postman.com/wp-content/uploads/2017/12/image9.png)
        4. **Variable highlighting and tooltips on hover:** Resolved variables are [highlighted](https://learning.postman.com/docs/sending-requests/variables/) in orange, while unresolved variables are red. Hovering over the variable displays a [tooltip](https://learning.postman.com/docs/sending-requests/variables/) with the variable’s current value and scope.[![screen](https://blog.postman.com/wp-content/uploads/2017/12/image5-1.png)](https://blog.postman.com/wp-content/uploads/2017/12/image5-1.png)
        5. **Using variables in scripts:** Variables are also available in the pre-request and test script sections. Since these sections are written in JavaScript, you will [initialize, retrieve, and define the scope](https://learning.postman.com/docs/sending-requests/variables/) of these variables in a different manner. This is a really powerful way to [extract data from a response and use this data in a subsequent request](https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/).[![screen](https://blog.postman.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-28-at-10.22.10-AM.png)](https://blog.postman.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-28-at-10.22.10-AM.png)
        6. **Logging variables:** [Log variables](https://learning.postman.com/docs/sending-requests/variables/) using `console.log()` in a script to inspect variables in the Postman console. This is especially helpful when troubleshooting, or to communicate explicitly to your fellow collaborators (or future self) during development and debugging.[![screen](https://blog.postman.com/wp-content/uploads/2017/12/image10.png)](https://blog.postman.com/wp-content/uploads/2017/12/image10.png)
        7. **Quick Look:** Clicking on the [Quick Look](https://learning.postman.com/docs/sending-requests/variables/) icon provides a preview displaying all your environment and global variables in one place. This is a good place to view a variable’s state once you send a request.[![screen](https://blog.postman.com/wp-content/uploads/2017/12/image6.png)](https://blog.postman.com/wp-content/uploads/2017/12/image6.png)
        8. **Variable editor**: From the Quick Look preview, clicking on one of the **Edit** links opens a modal to [edit environment or global variables](https://learning.postman.com/docs/sending-requests/variables/). Collection variables can be manually updated by [editing the collection details](https://learning.postman.com/docs/sending-requests/variables/).[![screen](https://blog.postman.com/wp-content/uploads/2017/12/image7-1.png)](https://blog.postman.com/wp-content/uploads/2017/12/image7-1.png)
        9. **Data variables:** [Data variables](https://learning.postman.com/docs/sending-requests/variables/) are available when using a data file with the collection runner. You can import the data as a CSV or JSON file, and then use the values from the data file inside HTTP requests and scripts. With data variables, you can test multiple instances of a request in one go using something like `{{username}` in the request builder or `pm.iterationData.get("username")` in the script sections.[![screen](https://blog.postman.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-28-at-10.29.38-AM.png)](https://blog.postman.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-28-at-10.29.38-AM.png)
        10. **Variable scopes:** Similar to working with variables in other programming languages, Postman resolves scopes according to a [variable scope hierarchy](https://learning.postman.com/docs/postman/variables-and-environments/variables/). Using variables within specific scopes allows you to reuse values efficiently. **Global** **variables** are commonly used to capture ephemeral states. **Collection** **variables** are best for values that are meant to be reused within the current collection. **Environment variables** are frequently used across multiple server environments - like development, staging, and production. For example, an endpoint using the variable `{{url}}` could easily switch between a development value of `dev.myapp.com` or a production value of `myapp.com`.![screen](https://blog.postman.com/wp-content/uploads/2017/12/image1-2.png)