ComfyUI > Nodes > Basic data handling > compare length

ComfyUI Node: compare length

Class Name

Basic data handling: CompareLength

Category
Basic/comparison
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

compare length Description

The CompareLength node compares container lengths to a specified value for data validation.

compare length:

The CompareLength node is designed to facilitate the comparison of the length of various container types, such as strings, lists, sets, and dictionaries, against a specified numerical value. This node is particularly useful for determining whether the size of a given container meets certain criteria, such as being equal to, not equal to, greater than, less than, greater than or equal to, or less than or equal to a specified length. By providing a straightforward mechanism to perform these comparisons, the CompareLength node helps streamline data validation and conditional logic processes, making it an essential tool for AI artists who need to manage and manipulate data structures efficiently.

compare length Input Parameters:

container

The container parameter accepts any data structure that can have a length, such as strings, lists, sets, or dictionaries. This parameter is crucial as it determines the subject of the length comparison. The node will attempt to calculate the length of this container, and if it is not a valid container type, the operation will fail. There are no specific minimum or maximum values for this parameter, as it depends on the type and content of the container provided.

operator

The operator parameter specifies the type of comparison to be performed between the container's length and the specified length value. It accepts one of the following options: ==, !=, >, <, >=, <=, with the default being ==. This parameter dictates the condition under which the comparison will return True, allowing you to tailor the node's behavior to your specific needs.

length

The length parameter is an integer that represents the value against which the container's length will be compared. This parameter is essential for defining the target length in the comparison operation. The default value is 0, and it must be a non-negative integer, as negative lengths are not meaningful in this context.

compare length Output Parameters:

result

The result output is a boolean value that indicates whether the comparison between the container's length and the specified length was successful based on the chosen operator. A True result means the condition was met, while False indicates it was not. This output is crucial for decision-making processes where the length of a container determines subsequent actions.

actual_length

The actual_length output provides the calculated length of the container. This integer value is useful for verification purposes, allowing you to confirm the size of the container being evaluated. It provides additional context to the result output, helping you understand why a particular comparison outcome was reached.

compare length Usage Tips:

  • Ensure that the container parameter is a valid data structure that supports length calculation, such as a list, string, set, or dictionary, to avoid errors.
  • Use the operator parameter to tailor the node's behavior to your specific needs, such as checking if a list has more than a certain number of elements or if a string is not empty.
  • When working with dictionaries, remember that the length refers to the number of key-value pairs, which can be useful for validating data completeness.

compare length Common Errors and Solutions:

Unknown operator: <operator>

  • Explanation: This error occurs when an invalid operator is provided in the operator parameter.
  • Solution: Ensure that the operator parameter is set to one of the valid options: ==, !=, >, <, >=, <=.

Non-container input

  • Explanation: This error arises when the container parameter is not a valid data structure that supports length calculation, such as an integer or None.
  • Solution: Verify that the container parameter is a valid type, such as a list, string, set, or dictionary, and not a non-container type like an integer or None.

compare length 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.

compare length