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
| Input | Type | Description | Default |
|---|---|---|---|
| Text | Text | The input string to be padded. | - |
| Length | Number | The target character length for the output string. | - |
| Padding | Text | The string to use for padding. If empty, defaults to a space character. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Output | Text | The padded text string. |
Configuration
| Property | Type | Description | Default |
|---|---|---|---|
| Start or End | Enum | Determines 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 topadEnd, 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)