# How can I create a random value?

**URL:** <https://community.postman.com/t/how-can-i-create-a-random-value/41193>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [November 17, 2022, 6:25am UTC](https://community.postman.com/t/how-can-i-create-a-random-value/41193 "2022-11-17T06:25:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyortush\_13](https://avatars.discourse-cdn.com/v4/letter/k/5fc32e/32.png) [@Kyortush\_13](https://community.postman.com/u/Kyortush_13)\
**Post date:** [November 17, 2022, 6:25am UTC](https://community.postman.com/t/how-can-i-create-a-random-value/41193/1 "2022-11-17T06:25:28Z")

</div>

How can I create a random value?

For example, body:

{

“Code”: {{param}},

“Name”: **random value**

}

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [November 18, 2022, 5:07am UTC](https://community.postman.com/t/how-can-i-create-a-random-value/41193/2 "2022-11-18T05:07:39Z")

</div>

@Kyortush_13 You need to use [dynamic variables](https://learning.postman.com/docs/writing-scripts/script-references/variables-list/).

For example if you need random first name,

```auto
{

“Code”: {{param}},

“Name”: {{$randomFirstName}}

}

```

Once you type the $ symbol you can see the list of random variables listed.

---

<div class="post-metadata">

**Author:** ![MARKYMARK292](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@MARKYMARK292](https://community.postman.com/u/MARKYMARK292)\
**Post date:** [November 23, 2022, 12:10pm UTC](https://community.postman.com/t/how-can-i-create-a-random-value/41193/3 "2022-11-23T12:10:44Z")

</div>

One of the simplest methods, other than maybe using the postman built in random values, is to generate a number from the date and time. I like to add a prefix of something meaningful, to differentiate from other random values.

```auto
pm.environment.set('MYRANDOMVALUE',"RND"+String((new Date()).getTime()).replace(/\compD/gi,'').substring(7));

```

or if you don’t want to save it as a variable and just use it within the request, you could simply create it as a local variable

```auto
var myRandomValue = "RND"+String((new Date()).getTime()).replace(/\compD/gi,'').substring(7));

```
