Nodes/ComfyUI Layer Style/LayerUtility: String Condition
ComfyUI Node Runs on cloud

LayerUtility: String Condition

String Condition (Layer Style)

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerUtility: String Condition
    • output
    • string
    ◄text—►
    ◄condition▾►
    ◄sub_string—►

    String Condition is the text equivalent of an if-check: it looks at a piece of text, asks a yes/no question about it, and gives you back a boolean you can branch on. Does this prompt contain the word "portrait"? Is this filename exactly hero.png? That's the job. If you're building workflows that route differently based on what a caption or prompt says, this is the node that reads the string and decides.

    The mechanism is plain string matching. It takes your text, checks it against a sub_string using the condition you pick, and returns whether the test passed. It also passes the original text straight through, so you can keep the wire going without a separate reroute.

    Three inputs, and they're all you need. text is the string you're testing (usually piped in from a prompt node, a filename, or upstream text). condition is a three-way dropdown:

    • include - true if text contains sub_string
    • exclude - true if it doesn't contain it
    • equal - true only on an exact, whole-string match

    And sub_string is what you're checking for. Simple as that.

    Two outputs come back: output, the BOOLEAN result, and string, which is the original text handed back unchanged. The boolean feeds a switch or gate - combine it with Boolean Operator if you need to AND/OR several checks together. The pass-through string output is there so this node can sit inline in a text chain without breaking it.

    Real uses: skipping a face-detailer when the prompt doesn't mention a person, choosing a different LoRA when a keyword shows up, tagging outputs by whether the caption matches a category, or filtering a batch of filenames. Anywhere a workflow should behave differently depending on what the text says, String Condition is the sensor.

    A couple of practical notes. include and exclude are substring checks, so "cat" will match "concatenate" - if you need a precise match, use equal. And matching is literal, so mind your casing and whitespace; "Portrait" and "portrait" are not the same string to this node.

    Installation is the pack, not the node: ComfyUI Layer Style ships this. Fastest is ComfyUI Manager - search "ComfyUI Layer Style," install, restart. Or manually: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt into ComfyUI's Python environment and restart. No models needed here.

    The failure mode you're most likely to hit has nothing to do with string matching - it's the pack itself not loading. Layer Style is a large pack with a heavy dependency list, and the recurring community headache is the whole thing showing "import failed" in the Manager, which pulls every one of its nodes (String Condition included) out of your menu in one go. A transformers version conflict is the usual trigger. If this node isn't where you expect it, the pack didn't import - reinstall it, try the Manager's "Try Fix," and reinstall the requirements into the right environment if needed. Once it loads, this node just works.

    Category😺dzNodes/LayerUtility/Data

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING—
    conditionCOMBO3 options: include, exclude, equal
    sub_stringSTRING—

    Outputs (2)

    NameTypeDescription
    outputBOOLEAN—
    stringSTRING—