ComfyUI > Nodes > ComfyUI > Length

ComfyUI Node: Length

Class Name

StringLength

Category
utils/string
Author
ComfyAnonymous (Account age: 872days)
Extension
ComfyUI
Latest Updated
2025-05-13
Github Stars
76.71K

How to Install ComfyUI

Install this extension via the ComfyUI Manager by searching for ComfyUI
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI 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

Length Description

Determines string length efficiently for text data analysis and manipulation in workflows.

Length:

The StringLength node is designed to determine the length of a given string, providing a straightforward way to measure the number of characters it contains. This node is particularly useful when you need to assess the size of text data, whether for validation, comparison, or processing purposes. By calculating the length of a string, you can make informed decisions about how to handle the text, such as truncating it, ensuring it meets certain criteria, or simply understanding its size for further operations. The node operates efficiently, making it a valuable tool in any workflow that involves string manipulation or analysis.

Length Input Parameters:

string

The string parameter is the text input for which you want to determine the length. It accepts a string value and can handle multiline text, allowing you to measure the length of both simple and complex text structures. There are no specific minimum or maximum values for this parameter, as it is designed to accommodate any string input. The primary function of this parameter is to provide the text data that the node will analyze to return its length.

Length Output Parameters:

length

The length output parameter represents the number of characters in the input string, including spaces and special characters. This integer value is crucial for understanding the size of the text, enabling you to perform operations based on the string's length. Whether you need to ensure a string meets certain length requirements or simply want to know its size, this output provides the necessary information in a clear and concise manner.

Length Usage Tips:

  • Use the StringLength node to validate input data by checking if the string length meets specific criteria, such as minimum or maximum length requirements.
  • Combine the StringLength node with other string manipulation nodes to create dynamic workflows that adapt based on the size of the text, such as truncating or padding strings to fit a desired length.

Length Common Errors and Solutions:

Input string is None

  • Explanation: This error occurs when the input string is not provided or is set to None.
  • Solution: Ensure that a valid string is passed to the node. Check the input source to confirm that it is supplying a non-null string value.

Unexpected data type for input

  • Explanation: The node expects a string input, but a different data type was provided.
  • Solution: Verify that the input is indeed a string. If the data comes from another node, ensure that it outputs a string type or convert it to a string before passing it to the StringLength node.

Length Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI
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 Playground, enabling artists to harness the latest AI tools to create incredible art.