Nodes/ComfyUI-off-suite/GW Number Formatting Node
ComfyUI Node

GW Number Formatting Node

Zero-Pad a Number for Filenames and Prompts

By Off-Live·Created 3 years ago·Updated 2 years ago· 0
GW Number Formatting Node
    • STRING
    input_number0
    width3

    You want your output files named img_007.png, not img_7.png. That's this entire node: take an integer, zero-pad it to a fixed width, hand you back a string. It's the sort of thing you don't think about until you're elbow-deep in a batch-save workflow, and then you're annoyed you have to reach for it.

    It lives in ComfyUI-off-suite and - fun detail - it's the pack's only node in the GW category. The OFF prefix on everything else and the GW on this one suggest the author folded it in from an older personal pack. It's a fossil with a job.

    What you plug in

    Two inputs, both plain integers:

    • input_number - the number to format (0 to 100,000,000).
    • width - how many digits to pad to (0 to 10, default 3).

    The output is a single STRING. Under the hood it's a Python printf-style format: f"%0{width}d" % input_number. So 7 with width 3 becomes "007", 42 with width 2 becomes "42" (already wide enough, no padding), and 12345 with width 3 stays "12345" - padding only adds leading zeros, it never truncates. That last behavior is worth knowing: a number wider than your width passes through untouched, not clipped.

    Where it actually helps

    • File naming - pipe the string into a save-image node's filename prefix so img_1 doesn't sort after img_10 in a folder listing. Zero-padding is what makes lexicographic order match numeric order.
    • Prompt building - if you're templating text that references a batch index or an iteration count, a padded string keeps your output tidy.
    • Seed labeling - when a seed doubles as an identifier in filenames, padding keeps widths consistent across the set.

    That's honestly it. It's a one-trick node with a very clean trick.

    The gotchas, such as they are

    The input is typed as an INT, so there's no float or negative handling - -7 will error against the 0 minimum, and a float will want to be converted upstream. And because it's just a string formatter, there's no "truncate to width" behavior: wide numbers come out as-is, which is usually what you want but can silently break a filename prefix convention if you assumed otherwise. If that matters, clamp the number before it reaches this node.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/Off-Live/ComfyUI-off-suite
    # or: ComfyUI Manager → search "ComfyUI-off-suite"
    

    No dependencies, no models, nothing to configure. Honestly, if this is the only node you wanted from the pack, it's a bit of a trek for a zero-pad - but once off-suite is in, it's there for all the face-crop and utility nodes that come with it.

    CategoryGW

    Inputs (2)

    NameTypeDefaultDescription
    input_numberINT00–100000000
    widthINT30–10

    Outputs (1)

    NameTypeDescription
    STRINGSTRING