Visit ComfyUI Online for ready-to-use ComfyUI environment
Converts string number to integer, handles formatting, provides fallback for parsing failures.
The String to Int node is designed to convert a string representation of a number into an integer. This node is particularly useful when you have numeric data stored as strings and need to perform arithmetic operations or other integer-specific tasks. It automatically strips any whitespace from the input string before attempting the conversion, ensuring that formatting issues do not interfere with the process. If the string cannot be successfully parsed into an integer, the node provides a fallback mechanism by returning a default integer value specified by the user. This feature ensures robustness and flexibility, allowing you to handle unexpected or malformed input gracefully.
This parameter represents the string input that you want to convert into an integer. The node will strip any leading or trailing whitespace from this string before attempting the conversion. This ensures that minor formatting issues do not prevent successful parsing. There is no explicit minimum or maximum value for this parameter, as it is a string, but it should ideally represent a valid integer to avoid fallback to the default value.
The default parameter specifies the integer value to return if the string cannot be parsed into an integer. This provides a safety net for cases where the input string is not a valid representation of an integer. The default value is set to 0, but you can specify any integer that suits your needs. This parameter ensures that the node can handle unexpected input gracefully without causing errors in your workflow.
The output of this node is an integer, which is the result of converting the input string. If the conversion is successful, the output will be the integer representation of the string. If the conversion fails, the output will be the default integer value specified by the user. This output is crucial for workflows that require numeric data in integer form, enabling further processing or calculations.
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.