ljust
Ljust — pad text on the right so your columns actually line up
- STRING
Sometimes you need text to be a specific width, and short strings need to grow to fit. ljust left-aligns a string inside a field of a given width, padding the right side with spaces (or any fill character you choose) until it's exactly that long. It's a formatting node, not a data node - you reach for it when you're building text output that needs to line up.
The realistic use is building fixed-width text: writing filenames that sort predictably, producing aligned records in a text file this pack can save, or generating a text overlay where names should sit on the same visual line. It pairs naturally with length - measure your longest string, then pad everything to that width.
How it works
This is Python's str.ljust(width, fillchar) behind the scenes. A few exact behaviors matter:
- If the string is already as long or longer than
width, nothing changes -ljustnever truncates. - Padding is added to the right, which is why it's "left justify".
- The
fillcharyou give it is clamped to its first character by the node's code - pass"-."and you get-, not an alternating pattern.
So "hi" with width=6 and fillchar="." gives "hi....". "longstring" with width=6 gives "longstring" back untouched.
Inputs and outputs
string- required, the text to pad.width- requiredINT, default 10, minimum 0. The target total length.fillchar- optionalSTRING, default" "(a space). The padding character.
Output is one STRING: the padded result.
Installing it
Part of the Basic data handling pack by StableLlama. ComfyUI Manager, search "Basic data handling", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Zero dependencies, no downloads - pure Python, installs clean and lives quietly in your custom_nodes folder. You'll find it under Basic/STRING.
Common issues
The padding character trap is real: default is a space, and a space-padded string loses its padding the moment it goes through any strip node or into a text field that trims whitespace. If you actually need the alignment to survive downstream, pad with a visible character like . or - instead. Also remember ljust will happily pad past a tiny width - set width from a length node if you want a uniform field across varying strings. And it never truncates, so if you wanted a hard maximum width, that's a different job (slice it or replace it first).
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| width | INT | 10 | — |
| fillcharopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |