ComfyUI > Nodes > Basic data handling > startswith

ComfyUI Node: startswith

Class Name

Basic data handling: StringStartswith

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

startswith Description

Determines if a string starts with a specified prefix, allowing optional start and end positions.

startswith:

The StringStartswith node is designed to determine if a given string begins with a specified prefix. This functionality is particularly useful when you need to verify the initial segment of a string against a known substring, ensuring that the string conforms to expected patterns or formats. The node provides flexibility by allowing you to specify optional start and end positions within the string, enabling you to focus the check on a specific portion of the string rather than its entirety. This can be especially beneficial in scenarios where only a segment of the string is relevant for the prefix check. By returning a boolean value, the node offers a straightforward way to incorporate conditional logic based on string content, making it a valuable tool for text processing and validation tasks.

startswith Input Parameters:

string

The string parameter represents the main text input that you want to check for a specific starting prefix. It is the primary subject of the operation, and the node will evaluate whether this string begins with the specified prefix. The default value is an empty string, which means if no input is provided, the node will operate on an empty string.

prefix

The prefix parameter is the substring you want to check against the beginning of the main string. This parameter is crucial as it defines the pattern or text that the main string should start with for the node to return True. Like the string parameter, its default value is also an empty string.

start

The start parameter is optional and specifies the position in the string where the prefix check should begin. By default, this is set to 0, meaning the check starts from the very beginning of the string. You can adjust this value to skip over initial characters and start the check from a different position, which can be useful for ignoring certain parts of the string.

end

The end parameter is also optional and determines the position in the string where the prefix check should stop. If set to 0 or a negative number, the check will continue to the end of the string. This parameter allows you to limit the scope of the prefix check to a specific segment of the string, providing more control over the operation.

startswith Output Parameters:

boolean

The output is a boolean value that indicates whether the input string starts with the specified prefix. If the string begins with the prefix, the node returns True; otherwise, it returns False. This output is essential for decision-making processes where the presence or absence of a specific starting pattern in a string determines subsequent actions.

startswith Usage Tips:

  • Use the start and end parameters to focus the prefix check on a specific part of the string, which can be useful when dealing with strings that have known structures or formats.
  • Remember that the prefix check is case-sensitive. If you need a case-insensitive check, consider converting both the string and the prefix to lowercase before using the node.

startswith Common Errors and Solutions:

Invalid start or end index

  • Explanation: If the start or end parameters are set to values outside the range of the string length, it might lead to unexpected results.
  • Solution: Ensure that the start and end indices are within the bounds of the string length. Adjust them accordingly to avoid out-of-range errors.

Empty string and prefix

  • Explanation: When both the string and prefix are empty, the node returns True, which might be unexpected.
  • Solution: Check for empty inputs before using the node to ensure that the operation aligns with your expectations.

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

startswith