Articles in this section

padLeft helper

The padLeft helper adds characters to the beginning of a string until it reaches a specified length. Use it to zero-pad identifiers, align values in fixed-width formats, or ensure consistent string lengths for downstream systems.

Syntax

{{padLeft 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. Maximum supported value is 999999.

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 an ID with leading zeros

{{padLeft record.customerId 10 "0"}}

Input:

{ "record": { "customerId": "CUST123" } }

Output: 000CUST123

Pad with spaces (default)

{{padLeft record.orderId 12}}

Input:

{ "record": { "orderId": "456" } }

Output: 456 (nine leading spaces, total length 12)

Usage notes

  • If the input is already equal to or longer than length, it's returned unchanged.
  • Fractional length values are floored: 5.7 is treated as 5.
  • The maximum supported length is 999999. Very large values may cause performance issues.
  • 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.