ComfyUI Node

center

Pad your text into neat columns

By StableLlama·Created about a year ago·Updated 4 days ago· 48
center
    • STRING
    string
    width20
    fillchar

    If you're writing text to a file, building a label, or producing any output a human or another tool is going to read, alignment matters. This node takes a string and centers it inside a fixed-width field, which sounds trivial until you need a column of labels to line up and don't feel like counting spaces by hand.

    What it does

    It's a direct wrapper over Python's str.center(width, fillchar). The input string gets padded on both sides so it sits in the middle of a field width characters wide. Default padding is a space; pass a fillchar and it uses that instead - think *** test ***.

    The inputs that matter:

    • string - what you're centering (required).
    • width - field size, default 20, clamped 0–1000 (required).
    • fillchar - the padding character, default " " (optional).

    One STRING output. That's the whole surface area.

    Two quirks worth knowing

    The source quietly coerces fillchar: if you type more than one character it keeps only the first, and if it's empty it falls back to a space. No error, just a silent trim. And if your string is longer than the width, the string comes back completely unchanged - padding never shrinks text. So "larger_string" through a width of 5 is exactly "larger_string".

    Where it earns its place

    The honest answer is that center is a niche pick in a pack full of them. You reach for it when you're generating text artifacts rather than images: a saved metadata block, an ASCII table, filenames that need a fixed visual width, or text you're passing to another program that expects columnar input. It sits nicely next to the pack's path and save-text nodes when you're producing a report from a workflow. It's also a friendly way to learn how the pack's padding family (center, ljust, rjust) differs - this one balances both sides, and any unevenness lands on the right.

    Installing

    Part of Basic data handling by StableLlama. In ComfyUI Manager search "Basic data handling" → Install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart ComfyUI. No model downloads, no pip deps to babysit - the pack declares zero runtime dependencies, so installing it can't break anything else you've got.

    Where people get burned

    The uneven-padding thing catches people: a 21-character width on a 5-character string gives six spaces left and seven right, because Python favors the right side when the split is odd. If you're depending on the padding being symmetrical, check the width parity. And don't expect this to do anything fancier than pad - it won't truncate, wrap, or trim. For that you want split/strip neighbors in the same pack.

    CategoryBasic/STRING

    Inputs (3)

    NameTypeDefaultDescription
    stringSTRING
    widthINT200–1000
    fillcharoptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING