Skip to main content
This page lists every Handlebars helper available in WireMock Cloud response templates on one page, grouped by type, with the syntax and an example for each. For guides that explain how to combine helpers for common tasks, start with Dynamic responses with templates.

Date and Time Helpers

now

Renders the current date/time with optional formatting and offset. Parameters:
  • format: Date format string (optional, defaults to ISO8601)
  • offset: Time offset (e.g., ‘3 days’, ‘-24 seconds’)
  • timezone: Timezone (optional, defaults to UTC)
Usage:
See Dates and Times for more details.

date

Manipulates existing date values with offset, timezone, and format changes. Parameters:
  • First parameter: Date value
  • format: Date format string (optional)
  • offset: Time offset (optional)
  • timezone: Timezone (optional)
Usage:
See Dates and Times for more details.

parseDate

Parses date strings into date objects. Parameters:
  • First parameter: Date string
  • format: Parser format string (optional)
Usage:
See Dates and Times for more details.

dateFormat

Formats date values to strings using predefined or custom formats. Parameters:
  • First parameter: Date value
  • Second parameter: Format name (full, long, medium, short) or custom format string
  • format: Alternative way to specify format string
Usage:
See Dates and Times for more details.

truncateDate

Truncates date/times to specific points. Parameters:
  • First parameter: Date value
  • Second parameter: Truncation point
Truncation points:
  • first minute of hour
  • first hour of day
  • first day of month
  • first day of next month
  • last day of month
  • first day of year
  • first day of next year
  • last day of year
Usage:
See Dates and Times for more details.

String Helpers

regexExtract

Extracts values from strings using regular expressions. Parameters:
  • First parameter: Input string
  • Second parameter: Regular expression pattern
  • Third parameter (optional): Variable name to assign captured groups
  • default: Default value if there is no match
Usage:
See String Helpers for more details.

regexReplace

Replaces all matches of a regular expression in a string with a replacement value. Parameters:
  • First parameter: Input string
  • Second parameter: Regular expression pattern
  • Third parameter: Replacement string (may reference capture groups with $1, $2, etc.)
Usage:
See String Helpers for more details.

trim

Removes whitespace from the start and end of strings. Usage:
See String Helpers for more details.

abbreviate

Truncates strings that exceed a specified length, adding ellipsis. Parameters:
  • First parameter: Input string
  • Second parameter: Maximum length
Usage:
Output: Mocking APIs helps... See String Helpers for more details.

capitalize

Capitalizes the first letter of each word. Parameters:
  • First parameter: Input string
Usage:
Output: Mock My Stuff See String Helpers for more details.

capitalizeFirst

Capitalizes only the first character of the string. Parameters:
  • First parameter: Input string
Usage:
Output: Mock my stuff See String Helpers for more details.

center

Centers text in a field of given width. Parameters:
  • First parameter: Input string
  • size: Field width (required)
  • pad: Padding character (optional, defaults to space)
Usage:
See String Helpers for more details.

cut

Removes all instances of a specified substring. Parameters:
  • First parameter: Input string
  • Second parameter: Substring to remove
Usage:
Output: mocking stubbing faults See String Helpers for more details.

defaultIfEmpty

Returns the input value if not empty, otherwise returns a default. Parameters:
  • First parameter: Input value
  • Second parameter: Default value
Usage:
See String Helpers for more details.

join

Joins multiple values or collections into a single string. Parameters:
  • Multiple values to join
  • Last parameter: Separator string
  • prefix: Optional prefix
  • suffix: Optional suffix
Usage:
See String Helpers for more details.

ljust

Left-aligns text in a field of given width. Parameters:
  • First parameter: Input string
  • size: Field width (required)
  • pad: Padding character (optional)
Usage:
See String Helpers for more details.

rjust

Right-aligns text in a field of given width. Parameters:
  • First parameter: Input string
  • size: Field width (required)
  • pad: Padding character (optional)
Usage:
See String Helpers for more details.

lower

Converts string to lowercase. Parameters:
  • First parameter: Input string
Usage:
Output: wiremock cloud See String Helpers for more details.

upper

Converts string to uppercase. Parameters:
  • First parameter: Input string
Usage:
Output: WIREMOCK CLOUD See String Helpers for more details.

replace

Replaces all occurrences of a substring with another. Parameters:
  • First parameter: Input string
  • Second parameter: Substring to find
  • Third parameter: Replacement string
Usage:
Output: the right way See String Helpers for more details.

slugify

Converts text to URL-friendly slug format. Parameters:
  • First parameter: Input string
Usage:
Output: mock-my-apis See String Helpers for more details.

split

Divides a string into a list of substrings using a delimiter. Parameters:
  • First parameter: Input string
  • Second parameter: Delimiter (treated as a literal string, not a regular expression)
Usage:
See String Helpers for more details.

stripTags

Removes all HTML/XML tags from string. Parameters:
  • First parameter: Input string
Usage:
Output: hi See String Helpers for more details.

substring

Extracts a portion of a string between indices. Parameters:
  • First parameter: Input string
  • Second parameter: Start index
  • Third parameter (optional): End index
Usage:
See String Helpers for more details.

wordWrap

Wraps text at specified line length. Parameters:
  • First parameter: Input string
  • Second parameter: Line length
Usage:
See String Helpers for more details.

yesno

Maps boolean/null values to customizable yes/no/maybe strings. Parameters:
  • First parameter: Boolean or null value
  • yes: Custom yes string (optional)
  • no: Custom no string (optional)
  • maybe: Custom maybe/null string (optional)
Usage:
See String Helpers for more details.

Encoding Helpers

base64

Encodes or decodes Base64 strings. Parameters:
  • First parameter: Input string
  • decode: Set to true for decoding (optional)
  • padding: Set to false to disable padding (optional)
Usage:
See String Encodings for more details.

urlEncode

Encodes or decodes URL strings according to HTTP URL encoding standard. Parameters:
  • First parameter: Input string
  • decode: Set to true for decoding (optional)
Usage:
See String Encodings for more details.

formData

Parses HTTP form data into an object. Parameters:
  • First parameter: Form data string
  • Second parameter: Variable name to assign
  • urlDecode: Set to true to URL decode values (optional)
Usage:
See String Encodings for more details.

Number Helpers

math

Performs arithmetic operations. Parameters:
  • First parameter: Left operand
  • Second parameter: Operator (+, -, *, /, %)
  • Third parameter: Right operand
Operators:
  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Division
  • %: Modulo (remainder)
Usage:
See Number Helpers for more details.

numberFormat

Formats numbers with control over style, decimal places, and locale. Parameters:
  • First parameter: Number to format
  • Second parameter (optional): Format type (integer, currency, percent) or format string
  • Third parameter (optional): Locale string
  • maximumFractionDigits: Maximum decimal places
  • minimumFractionDigits: Minimum decimal places
  • maximumIntegerDigits: Maximum integer digits
  • minimumIntegerDigits: Minimum integer digits
  • groupingUsed: Enable/disable digit grouping (default true)
  • roundingMode: Rounding mode (up, down, half_up, half_down, half_even, ceiling, floor)
Usage:
See Number Helpers for more details.

Random Value Helpers

randomValue

Generates random strings of specified type and length. Parameters:
  • length: Length of string (required for most types)
  • type: Type of random string (required)
  • uppercase: Convert to uppercase (optional)
Types:
  • ALPHANUMERIC: Letters and numbers
  • ALPHABETIC: Letters only
  • NUMERIC: Numbers only
  • ALPHANUMERIC_AND_SYMBOLS: Letters, numbers, and symbols
  • HEXADECIMAL: Hex characters (0-9, A-F)
  • UUID: UUID format (length not needed)
Usage:
See Random Values for more details.

randomInt

Generates random integers with optional bounds. Parameters:
  • lower: Lower bound (optional)
  • upper: Upper bound (optional)
Usage:
See Random Values for more details.

randomDecimal

Generates random decimal numbers with optional bounds. Parameters:
  • lower: Lower bound (optional)
  • upper: Upper bound (optional)
Usage:
See Random Values for more details.

pickRandom

Randomly selects a value from parameters or collection. Parameters:
  • First parameter: Collection (optional) or first value
  • Additional parameters: More values to choose from
  • count: Number of unique items to select (optional)
Usage:
See Random Values for more details.

random

Generates random test data using Faker library. Parameters:
  • First parameter: Faker key (e.g., ‘Name.firstName’, ‘Address.city’)
Usage:
See Generate Test Data for the complete list of available keys.

naughtyString

Returns a string from the Big List of Naughty Strings, for testing how clients handle hostile or unusual input. Parameters:
  • category: Limit the choice to one category, by name or slug (optional)
  • index: Return a fixed entry, counted from 0 within the list or category (optional)
Usage:
See Naughty Strings for more details.

JSON Helpers

jsonPath

Extracts values from JSON documents using JSONPath expressions. Parameters:
  • First parameter: JSON string or object
  • Second parameter: JSONPath expression
Usage:
See Working with JSON for more details.

jsonArrayAdd

Appends elements to a JSON array. Parameters:
  • First parameter: Existing array
  • Second parameter (optional): Item to add
  • maxItems: Maximum array size (optional)
  • flatten: Flatten nested arrays (optional)
  • jsonPath: Path to nested array (optional)
Usage:
See Working with JSON for more details.

jsonRemove

Removes elements from JSON arrays or keys from objects using JSONPath. Parameters:
  • First parameter: JSON object or array
  • Second parameter: JSONPath expression
Usage:
See Working with JSON for more details.

jsonMerge

Merges two JSON objects recursively. Parameters:
  • First parameter: Base object
  • Second parameter (optional): Object to merge
  • removeNulls: Remove null-valued attributes (optional)
Usage:
See Working with JSON for more details.

formatJson

Formats JSON in pretty or compact style. Parameters:
  • First parameter (optional): JSON to format
  • format: Style (pretty or compact, defaults to pretty)
Usage:
See Working with JSON for more details.

parseJson

Parses JSON string into object and assigns to variable. Parameters:
  • First parameter: JSON string or variable name
  • Second parameter (optional): Variable name to assign
Usage:
See Working with JSON for more details.

toJson

Converts any object to JSON string. Parameters:
  • First parameter: Object to convert
Usage:
See Working with JSON for more details.

jsonSort

Sorts a JSON array by a specified field using a JSONPath expression. Parameters:
  • First parameter: JSON array or object
  • Second parameter: JSONPath expression referencing the sort field
  • order: Sort direction (asc or desc, defaults to asc)
  • nulls: Placement of null/missing values (first or last, defaults to first)
Usage:
See Working with JSON for more details.

XML Helpers

xPath

Extracts values or sub-documents from XML using XPath 1.0 expressions. Parameters:
  • First parameter: XML string
  • Second parameter: XPath expression
Usage:
See Working with XML for more details.

soapXPath

Convenience helper for extracting values from SOAP body elements. Parameters:
  • First parameter: SOAP XML string
  • Second parameter: XPath expression (relative to SOAP body)
Usage:
See Working with XML for more details.

formatXml

Formats XML in pretty or compact style. Parameters:
  • First parameter (optional): XML to format
  • format: Style (pretty or compact, defaults to pretty)
Usage:
See Working with XML for more details.

Cryptographic Helpers

hash

Creates cryptographic hashes of text. Parameters:
  • algorithm: Hashing algorithm (required)
  • encoding: Output encoding (hex or base64, required)
Algorithms:
  • sha-1, sha-224, sha-256, sha-384, sha-512
  • sha3-224, sha3-256, sha3-384, sha3-512
  • md2, md5
Usage:
See Cryptographic Helpers for more details.

sign

Digitally signs data using a configured key. Parameters:
  • First parameter (inline form) or block content: Data to sign
  • algorithm: Signing algorithm (rsa-sha256 or hmac-sha256, defaults to rsa-sha256)
  • encoding: Output encoding (hex or base64, defaults to base64)
Usage:
See Cryptographic Helpers for more details.

x509Certificate

Outputs the X.509 certificate configured in your certificate settings. Parameters:
  • format: Output format (pem or base64, defaults to pem)
Usage:
See Cryptographic Helpers for more details.

base64Inflate

Decodes a Base64-encoded, DEFLATE-compressed string in a single operation. Primarily used for decoding SAML requests sent via the HTTP-Redirect binding. Parameters:
  • First parameter: Base64-encoded, DEFLATE-compressed string
Usage:
See Cryptographic Helpers for more details.

JWT Helpers

jwt

Generates signed JSON Web Tokens. Parameters:
  • alg: Signing algorithm (HS256 or RS256, defaults to HS256)
  • maxAge: Expiry duration (e.g., ‘12 days’)
  • exp: Expiry date (alternative to maxAge)
  • nbf: Not before date (optional)
  • iss: Issuer claim (optional)
  • aud: Audience claim (optional)
  • sub: Subject claim (optional)
  • Any additional parameters become custom claims
Usage:
See JWT Web Tokens for more details.

jwks

Generates JSON Web Key Set for RS256 public keys. Usage:
See JWT Web Tokens for more details.

Dynamic State Helpers

state

Retrieves a state value stored in a context by its key. Parameters:
  • First parameter: Key name (required)
  • context: Context name (optional, uses default context if not specified)
Usage:
See Dynamic State Basics for more details.

stateContext

Sets the default context for all state helpers within its block, avoiding repetition. Parameters:
  • First parameter: Context name or expression (required)
Usage:
See Dynamic State Basics for more details.

listState

Returns all state values within a given context as a collection. Parameters:
  • First parameter: Context name or expression (required)
Usage:
See Dynamic State Basics for more details.

Collection and Utility Helpers

assign

Creates a string variable for later use. Parameters:
  • First parameter: Variable name
Usage:
See Miscellaneous Helpers for more details.

val

Accesses values with default fallback, maintains type (unlike assign). Parameters:
  • First parameter: Value or expression
  • or/default: Default value if first parameter is absent
  • assign: Variable name to assign result
Usage:
See Miscellaneous Helpers for more details.

size

Returns the size of a string, list, or map. Parameters:
  • First parameter: String, list, or map
Usage:
See Miscellaneous Helpers for more details.

with

Creates a nested scope for accessing object properties. Parameters:
  • First parameter: Object
Usage:
See Miscellaneous Helpers for more details.

range

Generates an array of integers between two bounds. Parameters:
  • First parameter: Lower bound (inclusive)
  • Second parameter: Upper bound (exclusive)
Usage:
See Miscellaneous Helpers for more details.

array

Creates an array containing the specified values. Parameters:
  • Any number of values
Usage:
See Miscellaneous Helpers for more details.

arrayAdd

Adds an element to an array at specified position. Parameters:
  • First parameter: Array
  • Second parameter: Element to add
  • position: Index, start, or end (optional, defaults to end)
Usage:
See Miscellaneous Helpers for more details.

arrayRemove

Removes an element from an array at specified position. Parameters:
  • First parameter: Array
  • position: Index, start, or end (optional, defaults to end)
Usage:
See Miscellaneous Helpers for more details.

arrayJoin

Concatenates array values with a separator. Parameters:
  • First parameter: Separator string
  • Additional parameters: Values or array to join
  • prefix: String to prepend (optional)
  • suffix: String to append (optional)
Usage:
See Miscellaneous Helpers for more details.

hostname

Returns the hostname of the mock API. Usage:

Conditional Logic Helpers

if

Evaluates condition and renders block if true. Usage:
See Conditional Logic for more details.

unless

Evaluates condition and renders block if false. Usage:
See Conditional Logic for more details.

eq

Tests equality. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
See Conditional Logic for more details.

neq

Tests inequality. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
See Conditional Logic for more details.

gt

Tests greater than. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
See Conditional Logic for more details.

gte

Tests greater than or equal to. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
See Conditional Logic for more details.

lt

Tests less than. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
See Conditional Logic for more details.

lte

Tests less than or equal to. Parameters:
  • First parameter: Left value
  • Second parameter: Right value
Usage:
See Conditional Logic for more details.

and

Logical AND operation. Parameters:
  • Multiple boolean expressions
Usage:
See Conditional Logic for more details.

or

Logical OR operation. Parameters:
  • Multiple boolean expressions
Usage:
See Conditional Logic for more details.

not

Logical NOT operation. Parameters:
  • One boolean expression
Usage:
See Conditional Logic for more details.

contains

Tests if string or array contains a value. Parameters:
  • First parameter: String or array
  • Second parameter: Value to find
Usage:
See Conditional Logic for more details.

matches

Tests if string matches a regular expression. Parameters:
  • First parameter: String to test
  • Second parameter: Regular expression pattern
Usage:
See Conditional Logic for more details.

Iteration Helpers

each

Iterates over collections (arrays or objects). Usage:
Special variables:
  • @index: Current iteration index (zero-based)
  • @first: True if first iteration
  • @last: True if last iteration
See Conditional Logic for more details.