Skip to main content

Pad Text

Uncontrolled node

Overview

The Pad Text node extends a string to a specified character length by adding padding characters. It supports padding from either the beginning (left) or end (right) of the text using JavaScript's native padStart or padEnd methods.

If the input text is already equal to or longer than the target length, the text is returned unchanged (no truncation occurs). If the padding string is empty, a single space character is used by default.

Inputs

InputTypeDescriptionDefault
TextTextThe input string to be padded.-
LengthNumberThe target character length for the output string.-
PaddingTextThe string to use for padding. If empty, defaults to a space character.-

Outputs

OutputTypeDescription
OutputTextThe padded text string.

Configuration

PropertyTypeDescriptionDefault
Start or EndEnumDetermines whether to pad from the start (padStart) or end (padEnd) of the string.padStart

Runtime Behavior and Defaults

  • Uncontrolled Execution: This node runs automatically whenever its input data changes. It does not require an event trigger.
  • Padding Direction: When set to padStart, characters are added to the beginning of the string (left side). When set to padEnd, characters are added to the end (right side).
  • Default Padding: If the padding input is empty or not provided, the node uses a single space character (" ").
  • No Truncation: If the input text length already exceeds or equals the target length, the original text is returned without modification.
  • Repeat Padding: If the padding string is shorter than needed, it is repeated to fill the required length (e.g., padding "0" with length 5 on text "42" produces "00042").

Example

Scenario: Formatting a number to have leading zeros for a fixed-width display.

Inputs:

  • Text: "42"
  • Length: 5
  • Padding: "0"
  • Start or End: padStart

Output: "00042"

Scenario: Adding trailing spaces to align text in a column.

Inputs:

  • Text: "Hello"
  • Length: 10
  • Padding: " "
  • Start or End: padEnd

Output: "Hello " (5 trailing spaces)