Nodes/ComfyUI_yanc/๐Ÿ˜ผ> Int to Text
ComfyUI Node

๐Ÿ˜ผ> Int to Text

Turn a number into a zero-padded string for frame numbers and filenames

By ALatentPlaceยทCreated 2 years agoยทUpdated 2 years agoยท 80
๐Ÿ˜ผ> Int to Text
    • text
    โ—„int0โ–บ
    โ—„leading_zerosfalseโ–บ
    โ—„length5โ–บ

    A small conversion node that turns an INT into a STRING, with one genuinely useful extra: optional zero-padding. Plain type conversion alone would just be 5 โ†’ "5", but for anything sequential - frame numbers, batch indices, sortable output filenames - you usually want "00005" so files sort correctly and line up visually. That's what leading_zeros and length are for.

    The natural pairing is with something like Load Image From Folder's index-driven iteration, or any counter feeding into a Save Image filename via Text Combine - instead of your batch outputs sorting as 1, 10, 11, 2, 3... in a file browser, zero-padded names sort the way you'd expect.

    How it works

    Converts the integer to its string representation. If leading_zeros is on, it pads the front of that string with zeros until it reaches length characters total.

    The inputs and outputs that matter

    • int (default 0) - the number to convert.
    • leading_zeros (BOOLEAN, default false) - turn on zero-padding.
    • length (default 5, range 0โ€“5) - target string length when padding is on. Per the README's own example, 10 with leading_zeros on and length at 5 becomes "00010".

    One output: text (STRING) - feed it into Text Combine to build a filename, or anywhere else a string is expected instead of a raw number.

    How to install it

    Via ComfyUI Manager: search "yanc" or "YANC - Yet Another Node Collection," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ALatentPlace/ComfyUI_yanc
    

    then restart. No dependencies, no downloads.

    Common issues & troubleshooting

    No padding showing up even with a small number. Double-check leading_zeros is actually toggled on - it defaults to false, so a bare int value like 7 converts to "7", not "00007", until you flip that switch.

    Number gets truncated instead of padded. length caps out at 5 in this node's range - if your int value has more digits than length (say 123456 against a length of 5), padding can't help you shrink a number that's already longer than the target width; the node pads up to the length, it doesn't truncate down to it. For sequences that might run past 99999, this node's padding ceiling won't cover you.

    Just need a raw string, no padding. Leave leading_zeros off - the node still works as a plain int-to-string converter with no padding logic applied, which is the simpler and more common use case if you're not building sortable filenames.

    CategoryYANC/๐Ÿ˜ผ Basics

    Inputs (3)

    NameTypeDefaultDescription
    intINT00โ€“18446744073709550000โ€”
    leading_zerosBOOLEANfalseโ€”
    lengthINT50โ€“5โ€”

    Outputs (1)

    NameTypeDescription
    textSTRINGโ€”