Handlebars Helper Function: trim

Removes leading and trailing whitespace from a specified string value. The function can handle strings and attempts to convert other types to strings.

Availability

This helper is available in the Winter ’26 release of Marketing Cloud Next.

Syntax

{{trim subject}}

Parameters

Parameter Type Description
subject String Required. The string value to trim. Must be a string or convertible to a string.

Return Value

The function returns the input with all whitespace characters—including spaces, tabs, and newlines—removed from the beginning and end of the string. If the input is null, the function returns an empty string. If the input isn't a string, the function converts it to a string and trims the whitespace.