ComfyUI Node: count

Class Name

Basic data handling: StringCount

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

count Description

StringCount node counts occurrences of a substring in a string, with optional start and end positions.

count:

The StringCount node is designed to help you determine how many times a specific substring appears within a given string. This functionality is particularly useful when you need to analyze text data and identify the frequency of certain patterns or words. By allowing you to specify optional start and end positions, the node provides flexibility in narrowing down the search range, making it a versatile tool for text processing tasks. Whether you're working with large datasets or simple strings, the StringCount node offers a straightforward method to quantify occurrences, aiding in data analysis and decision-making processes.

count Input Parameters:

string

This parameter represents the main text in which you want to search for the substring. It is the primary input where the counting operation will be performed. The default value is an empty string, and there are no specific minimum or maximum length constraints, allowing you to input any string size.

substring

The substring parameter is the specific sequence of characters you are looking to count within the main string. Like the string parameter, it defaults to an empty string, and you can input any sequence of characters to search for within the main text.

start

This optional parameter allows you to specify the starting index from which the search for the substring should begin. It helps in limiting the search to a specific portion of the string. The default value is 0, meaning the search starts from the beginning of the string. The minimum value is 0, and there is no explicit maximum, but it should be within the bounds of the string length.

end

Another optional parameter, the end parameter, defines the index at which the search should stop. If set to 0 or a negative number, the search will continue to the end of the string. This parameter is useful for further narrowing down the search range. The default value is 0, and like the start parameter, it should be within the string's length.

count Output Parameters:

int

The output is an integer representing the number of times the specified substring appears within the given range of the main string. This count provides a quantitative measure of the substring's frequency, which can be used for further analysis or decision-making processes.

count Usage Tips:

  • To count occurrences of a substring in a specific part of a string, use the start and end parameters to define the range, which can optimize performance by reducing the search area.
  • If you want to count the substring throughout the entire string, you can leave the start and end parameters at their default values, ensuring a comprehensive search.

count Common Errors and Solutions:

IndexError: string index out of range

  • Explanation: This error occurs when the start or end parameters are set beyond the length of the string.
  • Solution: Ensure that the start and end values are within the bounds of the string length. Adjust them accordingly to avoid exceeding the string's limits.

ValueError: substring not found

  • Explanation: This error might occur if the substring is not present in the specified range of the string.
  • Solution: Double-check the substring and the range specified by start and end to ensure they are correct. If the substring is not expected to be found, handle this case in your logic to avoid errors.

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

count