Pad Zeroes
Turning 7 into \"0007\" so your batch filenames stop sorting wrong
- STRING
Here's the problem Pad Zeroes exists to solve: your batch saves video_1.mp4, video_2.mp4, ... video_10.mp4, and when you sort the folder by name, video_10.mp4 lands between video_1.mp4 and video_2.mp4. Lexicographic sorting doesn't care that 10 is bigger than 2 - it compares characters. Zero-padding fixes that: video_0001.mp4 through video_0010.mp4 sort in the order you actually meant. That's it. That's the whole job.
The node takes an INT in and returns a zero-padded STRING out. Two inputs, both INT: int_field (default 0) is the number you want padded, and quantity (default 4) is the total width of the result - so 7 with quantity 4 becomes "0007". The output is a STRING, not an INT. That trips people up, so say it again: it's for building strings (filenames, labels, prompts), and you can't wire it into an INT port downstream.
Under the hood it's a single call to Python's str.zfill(), and knowing that tells you the edge cases. zfill pads to a width, not a decimal count: feed it 1234 with quantity 3 and you get "1234" back unchanged - no truncation, no error. It also handles negative numbers sensibly, putting the zeros after the minus sign (-7 → "-007"), which is a nicer surprise than most formatting functions manage. And it only does decimal; if you ever want hex or fixed float formatting, this isn't the node.
Where it lives in a real workflow is the same batch-naming chain as its packmates: Count Files In Directory gives you how many clips already exist → Pad Zeroes turns 7 into "0007" → Concatenate assembles video_0007.mp4 → Save Video writes it with a name that sorts correctly beside everything else. It also works for zero-padding seeds into labels or experiment runs, though filename duty is clearly the intended use - it ships in a string-utility pack whose other nodes are built around that exact pipeline.
If the padding ever looks wrong, check quantity first: it's character width, not "number of digits past the front." Setting it too small is harmless (no truncation), and too large just gives you more leading zeros. Nothing here can crash or burn.
Install is the standard story for this pack: ComfyUI Manager, search "Arkl1te's Toolkit", or
cd ComfyUI/custom_nodes
git clone https://github.com/cybernaut4/comfyui_arkl1te_toolkit
then restart ComfyUI. There's no requirements.txt, no model files, and the pack declares zero Python dependencies - just ComfyUI's bundled comfy.comfy_types - so there's nothing extra to install and no dependency pile waiting to collide with your other nodes. A rare, boring, welcome thing in the custom-node world.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| int_field | INT | 0 | — |
| quantity | INT | 4 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |