ComfyUI Node: zfill

Class Name

Basic data handling: StringZfill

Category
Basic/STRING
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

zfill Description

StringZfill pads strings with zeros for consistent length, handling sign prefixes intelligently.

zfill:

The StringZfill node is designed to enhance string manipulation by padding a given string with zeros on the left side. This functionality is particularly useful when you need to ensure that strings have a consistent length, which is often required in formatting tasks, data alignment, or when preparing strings for numerical operations. The node intelligently handles strings with leading sign prefixes (+ or -), ensuring that the padding is applied after the sign, maintaining the integrity of the numerical representation. By using this node, you can easily standardize the length of strings, making them more uniform and easier to process in various applications.

zfill Input Parameters:

string

This parameter represents the input string that you want to pad with zeros. It is the primary subject of the operation, and the node will return a modified version of this string with added zeros on the left. The default value is an empty string (""), which means if no string is provided, the node will operate on an empty input.

width

The width parameter specifies the total length that the resulting string should have after padding. If the original string is shorter than this specified width, zeros will be added to the left until the string reaches the desired length. If the string is already equal to or longer than the specified width, no padding will occur. The default value for this parameter is 10, with a minimum value of 0, ensuring that you can specify any non-negative integer to control the padding length.

zfill Output Parameters:

string

The output is a single string that has been left-padded with zeros to meet the specified width. This output maintains any leading sign characters (+ or -) in their original position, ensuring that the numerical value of the string is preserved. The padded string is returned as a tuple containing one element, which is the modified string.

zfill Usage Tips:

  • Use the StringZfill node when you need to format numbers as strings with leading zeros, which is common in scenarios like generating fixed-length identifiers or aligning numbers in tabular data.
  • When dealing with negative numbers, rest assured that the node will handle the sign correctly, placing zeros after the sign to maintain the correct numerical representation.

zfill Common Errors and Solutions:

Invalid input type

  • Explanation: The input provided is not a string, which is required for the StringZfill node to function correctly.
  • Solution: Ensure that the input is a valid string. Convert any non-string inputs to strings before passing them to the node.

Width less than zero

  • Explanation: The width parameter is set to a negative value, which is not allowed.
  • Solution: Adjust the width parameter to be a non-negative integer, as negative values are not valid for this operation.

zfill Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.