Nodes/NIX ComfyUI Plugin/NIX_StringMatch
ComfyUI Node

NIX_StringMatch

Zero-pad a number so your batch of files sorts itself — 7 becomes 00007

By J-ChenX·Created 11 months ago·Updated 11 months ago· 2
NIX_StringMatch
    • text
    serial_number0
    figure5

    NIX_StringMatch is the node you use when you care that 7 sorts before 12 in a filename. It takes an integer and pads it with leading zeros to a fixed width, outputting the result as a string. That's the entire job: serial_number and figure in, text out. It's a formatting utility, not a matcher - the name is a little generous, but the behavior is unambiguous.

    This is a genuinely thin node, and that's fine. Padding numbers is a recurring annoyance in batch workflows, and having a one-input-one-dial node for it beats hand-rolling the logic every time you hit it.

    How it works

    • serial_number (required, INT, min 0) - the number to pad.
    • figure (required, INT, min 1) - the total width. Default 5.

    The output text is serial_number zero-filled to figure digits. Examples with default figure of 5:

    • 700007
    • 4200042
    • 100000100000 (already wider than 5, so no padding happens)

    Numbers wider than the width are left alone - it never truncates, only pads.

    Where it slots in

    The classic use is filenames. If you're saving a batch of frames or variants, 00007.png sorts before 00010.png everywhere that matters - your OS, your video encoder, downstream batch loaders (like NIX_PathLoading, which has a natural sort anyway, but external tools usually don't). Wire text into a save node's filename_prefix alongside the counter that drives your loop.

    It's also the natural companion to NIX_XYGridMapper's name output if you want zero-padded grid-sweep names, or any iterator that hands you an index and you need a string.

    Getting it installed

    One install covers the whole NIX pack - no models, no heavy deps:

    • ComfyUI Manager: search "NIX" / "NIX ComfyUI Plugin", or Install Custom Nodes → Git URL → https://github.com/J-ChenX/ComfyUI-NIX. Restart after.
    • By hand:
      cd ComfyUI/custom_nodes
      git clone https://github.com/J-ChenX/ComfyUI-NIX
      
      Restart ComfyUI. Under the "NIX" category.

    Gotchas

    • It only pads. Feed it a float and you'll want a cast upstream - the input is INT.
    • No truncation. figure: 3 with serial_number: 12345 returns 12345, not 345. If you need a fixed-length trimmed number, look elsewhere.
    • Quiet pack. No community discussion around NIX as of mid-2026, so this is a "read the source if unsure" situation - and the source is four lines, which is exactly as reassuring as it sounds.
    CategoryNIX

    Inputs (2)

    NameTypeDefaultDescription
    serial_numberINT0
    figureINT5

    Outputs (1)

    NameTypeDescription
    textSTRING