Nodes/Image Filter/Split String on character
ComfyUI Node

Split String on character

Turn '0.4, 20' Into Real Inputs for Your Sampler

By chrisgoringe·Created 2 years ago·Updated 2 months ago· 132
Split String on character
    • string
    • string
    • string
    • string
    • string
    • all
    string
    split,

    Here's a ComfyUI pain this node exists to solve: you want to type a few settings into a single text box - "denoise 0.4, 20 steps" - and have the graph actually use them. ComfyUI's text inputs are just strings, and most nodes want numbers. The Split String on character node is the first half of that trick: it takes one string, splits it on a separator, and gives you the pieces as separate outputs you can hand to the number-converter nodes.

    It's the workhorse of the cg-image-filter pack's extras system. The filter nodes give you three little extra fields, and the intended pattern - straight from the README - is to type something like 0.4, 20 into one of them, split it here, and convert each piece. An inpaint workflow becomes "type the denoise and the step count into a box while you're looking at the mask," which is exactly where you want to be making that call.

    How it works

    Give it a string and a split character (default ,), and it cuts the string into pieces, stripping whitespace from each. So "0.4, 20" comes out as 0.4 and 20. The magic value linebreak in the split field splits on newlines instead - handy for pasting a multi-line block.

    Outputs are five string slots and one all output that's the full list of pieces:

    • string (×5) - the first five pieces. Fewer than five, and the empty slots come out as empty strings. Note the fifth slot is just the fifth piece; anything past that lives in all.
    • all - the complete list, including every piece beyond the fifth. Feed this to a list-aware node if you need everything, not just the first few.

    The string outputs are what you wire into cg_String to Float (for the 0.4) and cg_String to Int (for the 20), then into your sampler's denoise and steps. Zero extra nodes needed.

    Installing it

    Part of chrisgoringe/cg-image-filter, so it installs with the pack. ComfyUI Manager, search "cg-image-filter" or "Image Filter":

    cd ComfyUI/custom_nodes
    git clone https://github.com/chrisgoringe/cg-image-filter
    

    Restart ComfyUI. No dependencies, no models, nothing to download.

    Gotchas

    The node splits on the raw character, so if your string contains a comma inside a value you'll get an extra piece. And it pads with empty strings rather than trimming the tail - feed all into Any List to String if you want a normalized single string back. Small thing worth knowing: whitespace is stripped, so 0.4, 20 and 0.4 , 20 parse identically. That's the whole point.

    Categoryimage_filter/helpers

    Inputs (2)

    NameTypeDefaultDescription
    stringSTRING
    splitSTRING,Split on this substring (or linebreak)

    Outputs (6)

    NameTypeDescription
    stringSTRING
    stringSTRING
    stringSTRING
    stringSTRING
    stringSTRING
    allSTRING