Postman Dynamic Variables

Dynamic variables are built-in Postman shortcuts that generate random, realistic data automatically. You use them directly in URLs, headers, or body fields without writing any JavaScript. Every time you send a request, dynamic variables produce fresh values.

What Makes Them Dynamic

A regular variable stores a fixed value you set manually. A dynamic variable generates a new value on every request. They use the same double-curly-brace syntax but start with a dollar sign:

Regular variable:  {{baseUrl}}        → always resolves to the same URL
Dynamic variable:  {{$randomInt}}     → generates a different number each time

Where to Use Dynamic Variables

Dynamic variables work anywhere you can use regular variables:

  • In the URL bar
  • In the request body
  • In headers
  • In query parameters

Most Useful Dynamic Variables

Random Numbers and IDs

VariableWhat It GeneratesExample Output
{{$randomInt}}Random integer between 0 and 1000742
{{$guid}}Globally unique identifier (UUID v4)b4f3a1d2-9e8c-4f7b-a0d1-2c3e4f5a6b7d
{{$timestamp}}Current Unix timestamp (seconds)1718000000
{{$isoTimestamp}}Current date and time in ISO 8601 format2024-06-10T08:30:00.000Z

Names and Personal Data

VariableExample Output
{{$randomFirstName}}Marcus
{{$randomLastName}}Thornton
{{$randomFullName}}Sarah Nguyen
{{$randomEmail}}olivia.santos@example.net
{{$randomUserName}}brave_eagle42
{{$randomPhoneNumber}}+1-555-297-4831

Addresses and Locations

VariableExample Output
{{$randomCity}}Portland
{{$randomCountry}}Brazil
{{$randomStreetAddress}}14 Oak Lane
{{$randomZipCode}}49302
{{$randomLatitude}}37.7749
{{$randomLongitude}}-122.4194

Commerce and Products

VariableExample Output
{{$randomProductName}}Ergonomic Granite Shoes
{{$randomPrice}}87.50
{{$randomColor}}maroon
{{$randomDepartment}}Clothing

Internet and Technical

VariableExample Output
{{$randomUrl}}https://sparse-division.net
{{$randomDomainName}}quiet-harbor.com
{{$randomIP}}192.168.43.7
{{$randomMACAddress}}3A:B2:C9:D4:E1:F0
{{$randomPassword}}9X!mKw2@qZ

Other Useful Variables

VariableExample Output
{{$randomBoolean}}true
{{$randomWord}}salmon
{{$randomJobTitle}}Senior Data Analyst
{{$randomCompanyName}}Horizon Systems Ltd.
{{$randomAbbreviation}}PNG

Real Example – Creating a Test User

Instead of hardcoding test data that becomes stale or causes duplicates, use dynamic variables in your POST body:

{
  "name": "{{$randomFullName}}",
  "email": "{{$randomEmail}}",
  "phone": "{{$randomPhoneNumber}}",
  "address": {
    "street": "{{$randomStreetAddress}}",
    "city": "{{$randomCity}}",
    "country": "{{$randomCountry}}"
  },
  "password": "{{$randomPassword}}"
}

Every time you send this request, Postman fills in completely different values. Run this 100 times in the Collection Runner and you generate 100 realistic, unique test users automatically.

Dynamic Variables in URLs

GET https://api.example.com/products?category={{$randomWord}}&page={{$randomInt}}

This tests your API's query parameter handling with a different random word and page number on each request.

Combine Dynamic Variables with Scripts

You can capture the generated values from a body in a pre-request script if you need to reuse the same value in multiple places:

// Generate once, reuse everywhere
const generatedEmail = pm.variables.replaceIn("{{$randomEmail}}");
pm.environment.set("newUserEmail", generatedEmail);

Now {{newUserEmail}} holds the same email value across multiple requests in your collection.

How to See All Available Dynamic Variables

Type {{$ in any Postman input field (URL, body, header). Postman displays an autocomplete dropdown listing all available dynamic variables with a short description of each.

Summary

Dynamic variables generate fresh random data on every request without any JavaScript. They use {{$variableName}} syntax and work in URLs, headers, and body fields. Categories cover IDs, names, addresses, commerce, and technical data. Use them in test data creation to generate realistic, unique values automatically every time you run a request.

Leave a Comment

Your email address will not be published. Required fields are marked *