Valid expressions

Valid expressions in mabl string template

The mabl string template can be used to create strings from constant values, random values, variables, and/or mathematical expressions. By setting a variable source to string template, you can use certain macros to generate random strings and also embed variable values into the string template. Both macros and variables are delimited by double curly braces: {{ }}

Macros are followed by a colon and a number, where the number indicates the number of random characters to be created. Here is the table of supported macros that can be used for string templates:





Upper and lower case letters



Lowercase letters (a-z)



Uppercase letters (A-Z)



Numbers (0-9)



Alphanumeric (letters and numbers)


Variables in string templates are also prepended by @. Here are some examples of valid expressions using variables that can be used for string templates:

  • {{@variable}}
  • Viewed {{@two}} elements

Valid expressions for generating random data

Mabl can also generate realistic random data using the string template. The random data expressions have to be enclosed in double curly braces and have to be prepended by "fake.". The syntax for this is in the form {{fake.type.subtype}}, e.g. {{}}. Below are some examples of how to use the string template to create random data.

Creating a random first nameCreating a random first name

Creating a random first name

Random monetary values can also be generated as well:

Creating a random monetary valueCreating a random monetary value

Creating a random monetary value

Even random titles can be created:

Below are some of the more commonly used expressions for creating random data:



Sample Result


Random first name



Random last name



Random street address

"840 Roberts Burg"


Random city name



Random US state name

"North Carolina"


Random US zip code



Random 2-letter country code



Random company name

"Sawayn Group"


Random phone number in one of multiple formats

"1-968-628-9831 x738"


Random phone number in the format ###-###-####



Random filler text

"consequatur omnis neque"


Random UUID



Random financial amount


Note: only the English locale is supported.


How to use faker.js documentation to build expression

faker.js documentation lists the valid types and subtypes in the form type.subtype. mabl expects the expression to be in the form {{fake.type.subtype}}.

Valid mathematical expressions

Mabl can perform basic math operations within the string template and save the results to a new variable or overwrite an existing variable. Formulating the expression is important for the correct results. The mathematical expressions must be enclosed by the double curly braces to be evaluated. Here are examples of how to create valid math expressions in the string template:

  1. Below is an example of using a digit macro within a math calculation. This will evaluate the macro (9) and add 100 to the macro.
  1. Math expressions will be evaluated under the PEMDAS rules.
    Example: {{5 + 3 / 2}} will evaluate to 6.5
  2. Use parenthesis to evaluate math operations in the specified order.
    Example: {{(5 + 3) / 2}} will evaluate to 4
  3. Concatenate strings such as $ or % to create a string value from the results with units.
    Example: ${{(5 + 3 ) / 2}} will evaluate to $4

Advanced math expressions

Mabl also supports certain math functions to format the numerical result from a math expression. Below are the functions that are supported:

  1. round(number, numberOfDecialPlaces) - Rounds the result of a math calculation to numberOfDecialPlaces number of decimal places.


JavaScript Floating Point Precision

Due to rounding errors stemming from how floating point numbers are stored, arithmetic expressions like 0.1 + 0.2 === 0.3 will return false. To resolve this, the result needs to be rounded, e.g. round(0.1 + 0.2, 1) or (0.1 + 0.2).toFixed(1).

  1. abs(number) - Returns the absolute value of a math calculation
    Example: {{abs(-6)}} will evaluate to 6

  2. randomInt(min, max) - Returns a random integer greater than or equal to min but LESS than max
    Example: {{randomInt(0, 11)}} will return a random integer between 0-10.

Did this page help you?