* set the new repo banner and icon * improve the README files by using github md alerts
2.6 KiB
Node reference: Format (String / Multiline)
Overview
The Format nodes are very simple yet powerful nodes, that are based on the standard Python string format() method.
They exist in 2 flavors: String or Multiline.
They are useful to create a string from a template, and any number of inputs.
Note
Inputs can be of the following ComfyUI types:
STRING,INT,FLOAT,BOOLEAN.
How to use
Here we will just cover the most basic usage, but please note that Python string format() allows to do very interesting things, beyond the standard string replacement: padding, truncating, ...
Simple usage
The node takes any number of inputs, that are automatically incremented: arg0, arg1, ...
Given the following template: first arg by name: {arg0}, second by index: {1}, and 2 input strings (tata and toto), we will get the resulting string: first arg by name: tata, second by index: toto.
Here we see that we can reference the inputs either by their name (argN), or by their index (starting at 0).
Straightforward, isn't it?
Tip
This way, it's very simple to concatenate 2 strings, append text to a string, pad / truncate, ... many operations in one single node!
And last but not least: at stated above, it can take other types than strings: integer, float, boolean (and surely others).
Going further
For more details and advanced techniques, you can check:
- the tutorials of the
Formatnodes - a guide with different techniques (padding, ...)
- format specification mini-language (python.org)
Inputs / Widgets / Outputs
Inputs (unlimited)
| input name | type | description | comment |
|---|---|---|---|
| arg0 | STRING, INT, FLOAT, BOOLEAN | input value | can also be referenced by index: 0 |
| ... | |||
| argN | STRING, INT, FLOAT, BOOLEAN | input value | can also be referenced by index: N |
Widgets
| widget name | type | description | comment |
|---|---|---|---|
| format | STRING | template string |
Outputs
| output name | type | description | comment |
|---|---|---|---|
| formatted | STRING | result string after format |