ComfyUI Node

Number Padder

Turn 7 into 0007 without a second thought

By lazniak·Created 2 years ago·Updated 11 months ago· 7
Number Padder
    • STRING
    number42
    padding_length4

    Number Padder is a zero-padding utility: give it an integer and a target length, it hands back a string with leading zeros so the number has exactly that many digits. 42 with padding 4 becomes "0042". That's the node.

    In the videoclipgenerator world this exists to solve a very real annoyance: frame numbers and render sequences don't sort correctly unless they're zero-padded. frame_9.mp4 sorts after frame_10.mp4 in naive alphabetical order, and the whole pack is about producing numbered clips (sc_00001.mp4, sc_00002.mp4...) that need to assemble in the right order downstream. If you're generating per-shot filenames or frame numbers to feed a video assembler, this is the node that makes your numbering sort-friendly. It's also just generally useful for building consistent IDs and timestamps in any workflow - classic value-node territory from the KB's node-plumbing essay.

    What matters

    Only two inputs, and both are obvious:

    • number (INT, default 42) - the value to pad. Floor is 0, ceiling is 999,999,999.
    • padding_length (INT, default 4, range 1–20) - how many digits the output string should be.

    One output: STRING - the padded result.

    The implementation is Python's str.zfill(), which has one behavior worth knowing: zfill pads, but it never truncates. Ask for 4 digits on the value 123456 and you get "123456", not "1234". So the node's README blurb about "overflow protection" is really just "returns the full number anyway," which is the sensible thing to do.

    Install

    Part of the videoclipgenerator pack - Manager search "videoclipgenerator", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lazniak/videoclipgenerator
    cd videoclipgenerator
    pip install -r requirements.txt
    

    Restart, and it's under "formatting". No dependencies, no models, nothing to break.

    Honest take

    It's a one-liner wearing a custom-node costume, and it knows it. You could just as easily type zfill into any Python node, but if you're working in pure graph-land this saves you the detour. Nice touch: it's declared as an output node, so it's meant to sit at the end of a chain producing a value you actually want to see. The whole pack's README is marketing-speak, but a utility this trivial is hard to get wrong - it pads numbers, and it does. If you don't need zero-padded numbers, skip it entirely; there's nothing else hiding in here.

    Categoryformatting

    Inputs (2)

    NameTypeDefaultDescription
    numberINT420–999999999
    padding_lengthINT41–20

    Outputs (1)

    NameTypeDescription
    STRINGSTRING