ComfyUI > Nodes > ComfyUI > Compare

ComfyUI Node: Compare

Class Name

StringCompare

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

Compare Description

Versatile utility for comparing strings based on specific criteria, with options for case sensitivity.

Compare:

The StringCompare node is a versatile utility designed to facilitate the comparison of two strings based on specific criteria. It allows you to determine if one string starts with, ends with, or is equal to another string, providing a straightforward way to perform these common string operations. This node is particularly useful in scenarios where you need to validate or filter text data, ensuring that strings meet certain conditions. By offering options for case sensitivity, it provides flexibility in handling text comparisons, making it a valuable tool for tasks that require precise string matching.

Compare Input Parameters:

string_a

string_a is the first string to be compared. It serves as the primary string against which the comparison operations will be performed. This parameter can contain multiple lines of text, allowing for comprehensive string analysis.

string_b

string_b is the second string used in the comparison. It acts as the reference string for the operations, such as checking if string_a starts with, ends with, or is equal to string_b. Like string_a, it supports multiline text.

mode

The mode parameter determines the type of comparison to be executed. It offers three options: "Starts With," "Ends With," and "Equal." Each option specifies a different comparison operation, allowing you to tailor the node's behavior to your specific needs.

case_sensitive

case_sensitive is a boolean parameter that dictates whether the comparison should consider case differences. When set to True, the comparison is case-sensitive, meaning "Hello" and "hello" would be considered different. The default value is True, ensuring precise matching unless otherwise specified.

Compare Output Parameters:

boolean

The output is a boolean value that indicates the result of the comparison. It returns True if the specified condition (based on the mode and case_sensitive settings) is met, and False otherwise. This output is crucial for decision-making processes where string validation is required.

Compare Usage Tips:

  • Use the case_sensitive parameter to control whether the comparison should ignore case differences, which can be particularly useful when dealing with user input or data from varied sources.
  • Select the appropriate mode based on your specific requirement, such as using "Starts With" for prefix checks or "Equal" for exact matches, to ensure the node performs the desired operation.

Compare Common Errors and Solutions:

Invalid mode selection

  • Explanation: The mode parameter must be one of the predefined options: "Starts With," "Ends With," or "Equal."
  • Solution: Ensure that the mode parameter is set to one of the valid options to avoid execution errors.

Case sensitivity mismatch

  • Explanation: If case_sensitive is set to True, the comparison will fail if there are case differences between string_a and string_b.
  • Solution: Adjust the case_sensitive parameter to False if you want to perform a case-insensitive comparison.

Compare 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.