Handlebars format
Handlebars format: formats a value with a format string and, if given, a type.
Next
Runtime verified
Differs from official docs
Test scripts included
Formats a value with a format string and, if given, a type.
Syntax
{{format subject formatString [type] [culture]}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subject |
any | Yes | Input value. |
formatString |
string | Yes | Pattern that shapes the output. |
type |
string | No | Format type: date or numeric. |
culture |
string | No | Culture code, such as en-US. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{format 1234.567 "N2;N0;N2"}}renders1,234.57, as documented.{{format -1234.567 "N2;(F2);N0"}}renders-1,234.57. The documented result is(1,234.57).{{format 123 "000000"}}renders123. The documented result is000123.
Show Next test script
Differs from official docs
- The reference says a format string may be split by
;into one section each for numbers above, below and equal to zero, and its own example formats-1234.567with"N2;(F2);N0"as(1,234.57). In Marketing Cloud Next (tested 2026-11-22):{{format -1234.567 "N2;(F2);N0"}}rendered-1,234.57: the first section was used and the negative section ignored. The positive case,{{format 1234.567 "N2;N0;N2"}}, rendered1,234.57as documented. Details - The reference lists the custom format
000000as padding123with leading zeros to000123. In Marketing Cloud Next (tested 2026-11-22):{{format 123 "000000"}}rendered123, without the leading zeros. Details
Marketing Cloud Next
Differs from the documentation
{{format 1234.567 "N2;N0;N2"}} gives 1,234.57 as documented. The section for negative numbers is ignored: {{format -1234.567 "N2;(F2);N0"}} renders -1,234.57 instead of (1,234.57). Zero padding is ignored too: {{format 123 "000000"}} renders 123 instead of 000123. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
Format— does a similar job in AMPscript, with a different call shape - AMPscript
FormatDate— does a similar job in AMPscript, with a different call shape - Official reference