JSON TransformString
padEnd
Pad the end of a string to a target length
padEnd
Pads the end of a string with pad_char until its length reaches length bytes. If the string is already long enough, it is returned unchanged.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
length | integer | Yes | — | Target length in bytes. |
pad_char | string | No | " " | Padding string. Empty values fall back to a space. |
Example
Input
"42"Operation
{ "type": "padEnd", "options": { "length": 5, "pad_char": "." } }Output
"42..."In a Circuit Step
{
"name": "right_pad_label",
"description": "Right-pad a label with dots to a fixed width",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ input.label }}",
"operations": [
{ "type": "padEnd", "options": { "length": 20, "pad_char": "." } }
]
},
"outputs": [
{
"name": "padded_label",
"description": "Label right-padded with dots to 20 bytes",
"value": "${{ right_pad_label.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
padEnd: expected stringif the input is not a string. lengthis measured in bytes, not characters.pad_charmay be longer than one character; it's appended whole-string until the target length is reached, so the output may exceedlengthifpad_chardoesn't divide evenly.- An empty
pad_charfalls back to a single space.