ComfyUI > Nodes > ComfyUI > Contains

ComfyUI Node: Contains

Class Name

StringContains

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

Contains Description

Determines substring presence in larger strings, aiding text analysis, data validation, and content filtering with case sensitivity support.

Contains:

The StringContains node is designed to help you determine whether a specific substring exists within a larger string. This node is particularly useful when you need to verify the presence of certain text patterns or keywords within a given string, which can be essential for tasks such as text analysis, data validation, or content filtering. By providing a straightforward method to check for substrings, the StringContains node simplifies the process of string analysis, allowing you to focus on the creative aspects of your work without getting bogged down by complex string manipulation logic. Its ability to handle case sensitivity further enhances its utility, making it adaptable to various scenarios where precise text matching is required.

Contains Input Parameters:

string

The string parameter represents the main text in which you want to search for a specific substring. This is the larger body of text that will be examined to determine if it contains the specified substring. The parameter accepts multiline strings, allowing for comprehensive text analysis across multiple lines.

substring

The substring parameter is the specific sequence of characters you are looking to find within the main string. This parameter also supports multiline input, enabling you to search for complex text patterns that span multiple lines.

case_sensitive

The case_sensitive parameter is a boolean option that determines whether the search should consider case differences between the main string and the substring. If set to True, the search will be case-sensitive, meaning that the exact case of the characters must match. If set to False, the search will ignore case differences, allowing for a more flexible matching process. The default value is True.

Contains Output Parameters:

contains

The contains output parameter is a boolean value that indicates whether the specified substring was found within the main string. A value of True means the substring is present, while False indicates it is not. This output provides a clear and concise result of the substring search, allowing you to make informed decisions based on the presence or absence of the desired text.

Contains Usage Tips:

  • To ensure accurate results when searching for specific keywords or phrases, set the case_sensitive parameter to True if the exact case is important, such as when dealing with case-sensitive identifiers or proper nouns.
  • Use the case_sensitive parameter set to False when you want to perform a more general search that ignores case differences, which can be useful for finding text patterns regardless of capitalization.

Contains Common Errors and Solutions:

Invalid input type for string or substring

  • Explanation: This error occurs when the input provided for either the string or substring parameters is not of the expected string type.
  • Solution: Ensure that both the string and substring inputs are valid strings. If you are using variables, verify that they contain string data before passing them to the node.

Substring not found

  • Explanation: This is not an error message per se, but a possible outcome where the contains output is False, indicating that the substring was not found in the main string.
  • Solution: Double-check the substring value to ensure it is correctly specified. Consider adjusting the case_sensitive parameter if case differences might be affecting the search results.

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