rjust
Rjust — right-align your text so the numbers line up like a ledger
- STRING
Numbers read right-aligned. A column of 7, 42, and 1000 lines up on the right and your eye catches the values instantly; left-aligned, they look like a shuffled deck. rjust is the node that pads a string on the left to a fixed width, so short values grow into a right-aligned field. It's ljust's mirror, and it's the one you want whenever the things being aligned are numbers or IDs.
Reach for it when you're building text output that should look structured - tabular data you're about to save with this pack's file nodes, zero-padded identifiers where alignment matters, or fixed-width records where position within a line carries meaning. It also pairs with length if you want to right-align every value to match the longest one in the set.
How it works
Python's str.rjust(width, fillchar). It pads on the left with the fill character until the string hits width. Like ljust, it never truncates - a string longer than width comes back untouched. And the node clamps your fillchar to its first character: pass "-." and you get - everywhere.
"7".rjust(4, " ")→" 7""7".rjust(4, "0")→"0007""1000".rjust(4, "0")→"1000"(already wide enough, unchanged)
Inputs and outputs
string- required, the text to pad.width- requiredINT, default 10, minimum 0. Target total length.fillchar- optionalSTRING, default" ". The padding character.
Output is one STRING - the padded result.
Installing it
Ships in the Basic data handling pack by StableLlama. ComfyUI Manager, search "Basic data handling", install, restart. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Pure Python, zero dependencies, no downloads - the whole pack installs in seconds and never asks for a model file. Under Basic/STRING in the menu.
Common issues
Same family quirks as ljust. A space fillchar is the default, and space-padding vanishes if the string later passes through any trimming or a text field that strips whitespace - use 0 or another visible character if the padding has to survive. And remember it never truncates: rjust on an over-long string is a no-op, so if you wanted a hard cap on width, that's a different node's job. The classic practical trap is confusing which side gets padded - rjust pads left to align right. Get them backwards and your ledger reads like a ransom note.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| width | INT | 10 | — |
| fillcharopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |