Skip to content

__RandomString

JMeter __RandomString function reference: syntax, parameters, and practical examples for parameterizing test plans with dynamic values.

Difficulty
intermediate
Guide type
reference
Estimated read time
1 min read
Last verified version
Verified JMeter 5.6

Also documented in context in the full Functions and Variables reference.

TL;DR: __RandomString generates a random string of a given length, optionally from a specific character set โ€” handy for unique-ish usernames, search terms, or filler payload data.

The RandomString function returns a random String of length using characters in chars to use.

NameRequiredDescription
LengthYesA number length of generated String
Characters to useNoChars used to generate String
Variable NameNoA reference name for reusing the value computed by this function.

Examples:

Terminal window
\${__RandomString(5)}

will return a random string of 5 characters which can be readable or not

Terminal window
\${__RandomString(10,abcdefg)}

will return a random string of 10 characters picked from abcdefg set, like cdbgdbeebd or adbfeggfad, โ€ฆ

Terminal window
\${__RandomString(6,a12zeczclk, MYVAR)}

will return a random string of 6 characters picked from a12zeczclk set and store the result in MYVAR, MYVAR will contain string like 2z22ak or z11kce, โ€ฆ

${__RandomString(5)} โ†’ random 5-char string
${__RandomString(10,abcdefg)} โ†’ 10 chars from "abcdefg" only
${__RandomString(6,a12zeczclk,myVar)} โ†’ stored in variable "myVar" too

Not cryptographically random โ€” donโ€™t use this to generate anything security-sensitive (tokens, secrets). For unique IDs instead of random noise, see __UUID.

On this page