The padRight helper adds characters to the end of a string until it reaches a specified length. Use it to right-pad identifiers, align values in fixed-width formats, or ensure consistent string lengths for downstream systems.
Syntax
{{padRight value length "char"}}
value -- The string or number to pad. Required. Non-string inputs (numbers, booleans) are converted to strings before processing. Arrays of primitive values are converted to a comma-separated string. Objects and object arrays produce unusable output.
length -- The total length of the output string. Required. If the input is already equal to or longer than length, the value is returned unchanged. Fractional values are floored (e.g. 5.7 → 5). Negative, zero, or non-numeric values return the input unchanged.
char -- The character or string to pad with. Optional. Defaults to a space. If a multi-character string is provided, the pattern repeats and is truncated to fit the target length exactly.
Examples
Pad a code with trailing asterisks
{{padRight record.code 6 "*"}}
Input:
{ "record": { "code": "XYZ" } }
Output: XYZ***
Pad with trailing spaces (default)
{{padRight record.orderId 8}}
Input:
{ "record": { "orderId": "123" } }
Output: 123 (five trailing spaces, total length 8)
Usage notes
- If the input is already equal to or longer than
length, it's returned unchanged. - Fractional
lengthvalues are floored:5.7is treated as5. - If the padding character is a special HTML character such as
&,>, or<, use triple braces ({{{ }}}) to prevent HTML escaping. - Do not pass objects or object arrays -- the output will be unusable.