Visit ComfyUI Online for ready-to-use ComfyUI environment
The `FormattedString` node creates dynamic strings by replacing placeholders with specified values, supporting advanced formatting and data insertion for AI art projects.
The FormattedString node is a versatile utility designed to create dynamic strings by replacing placeholders with specified values. It leverages Python's str.format() method, allowing you to format strings with precision and flexibility. This node is particularly useful for generating filenames, labels, or any text that requires variable content. It supports advanced formatting options, such as rounding numbers or padding with zeros, and can handle special characters by doubling curly braces. Additionally, it incorporates a "search & replace" feature using a JavaScript context, enabling you to insert dynamic data like timestamps or other node outputs before execution. This makes the FormattedString node a powerful tool for both string manipulation and data retrieval in your AI art projects.
The fstring parameter is the template string containing placeholders that will be replaced with actual values. It supports multiline input and defaults to the format {a}_{b}_{c}_{d}. This parameter is crucial as it defines the structure of the output string, allowing you to specify where and how each input value should appear. The placeholders within the string should match the names of the input parameters to ensure correct substitution.
The a parameter is an optional input that provides a value to replace the {a} placeholder in the fstring. It can be of any type, and if not specified, it defaults to an empty string. This parameter allows you to dynamically insert content into your formatted string, making it adaptable to various contexts.
The b parameter is an optional input that provides a value to replace the {b} placeholder in the fstring. Like a, it can be of any type and defaults to an empty string if not provided. This flexibility enables you to customize the output string based on different input scenarios.
The c parameter is an optional input that provides a value to replace the {c} placeholder in the fstring. It accepts any type of input and defaults to an empty string if not specified. This parameter further enhances the node's ability to generate tailored strings by incorporating diverse data inputs.
The d parameter is an optional input that provides a value to replace the {d} placeholder in the fstring. It can be of any type and defaults to an empty string if not provided. This parameter completes the set of inputs that can be used to populate the placeholders in the formatted string, offering comprehensive customization options.
The string output parameter is the final formatted string with all placeholders replaced by their respective values. This output is a single string that reflects the template defined in the fstring parameter, populated with the data provided through the input parameters. It is the primary result of the node's execution, delivering a customized string ready for use in your projects.
{a:.2f} to control the appearance of numbers, such as rounding floats to two decimal places.{{ }} to prevent them from being interpreted as placeholders.fstring contains a placeholder {a} but no corresponding input value is provided.a parameter or remove the {a} placeholder from the fstring.fstring contains unmatched curly braces, which are interpreted as placeholders.{{or}}.fstring do not match the input parameter names.fstring correspond to the provided input parameters.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.