TagIf
Branch your prompt on whether certain tags are present
- output1
- output2
- output3
- else_output1
- else_output2
- else_output3
- tagin
TagIf is the pack's branch statement. You give it a tag string (say, WD14 Tagger output), a list of tags to look for, and two sets of outputs - one used when a match is found, one when it isn't. The classic use from the README: a tagged image that contains certain content routes to one positive/negative prompt pair, and anything else gets a different pair. It's prompt-level if/else without writing any Python.
If you've fought with ComfyUI's lack of conditional logic before, this is the cheap version of what Impact Pack's conditionals do, scoped to exactly one problem: "do these tags appear?"
How it works
The tags input and the find input are both parsed the same way the rest of the pack parses tags - normalized to lowercase underscores, (tag:1.2) emphasis stripped for matching but remembered. So find: cat_ears matches (cat_ears:1.1) in your tags.
The anytag toggle decides what counts as a hit:
True(default) - any one tag fromfindbeing present is enough.False- all tags infindmust be present. Useful for compound conditions like "has cat ears AND tail."
If the condition is true, output1, output2, output3 flow through and the three else_output* ports return empty strings. If false, it's the mirror image: else outputs flow, main outputs are empty. A tagin BOOLEAN output also tells you the raw result, which is handy for driving a boolean gate or a UI display node.
The output pattern that catches people
The six string outputs are always live - they just return "" on the side that didn't win. So don't wire both sides into a text encoder and expect an empty string to be ignored; feed the two branches into a string combine or just pick the side you want. If all you need is the yes/no, read tagin and ignore the strings entirely.
Also worth knowing: output1 is a required input, not optional like the others - the node won't even render until you've typed something in it, even if you only care about tagin. Set it to a placeholder if you're building a pure boolean gate.
Where it slots in
The natural chain in this pack: TagFilter or TagSelector trims a tagger's output down to the category you care about, TagIf reads whether a specific tag survived, and its tagin feeds something like TagSwitcher or a boolean router. A common one: "if the image contains animal_ears, suppress them in the prompt; otherwise leave it alone." That's exactly what this node was written for.
Install
Identical to the rest of the pack - ComfyUI Manager search "comfyui_tag_filter", or:
cd ComfyUI/custom_nodes
git clone https://github.com/sugarkwork/comfyui_tag_fillter
Restart and it's under the string category. No dependencies, no models. The only real gotcha is pack-wide: matching is only as good as the tag normalization, so whitespace between words in find is treated as an underscore - type long_hair, not long hair.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| tags | STRING | — | |
| find | STRING | — | |
| anytag | BOOLEAN | true | — |
| output1 | STRING | — | |
| output2opt | STRING | — | |
| output3opt | STRING | — | |
| else_output1opt | STRING | — | |
| else_output2opt | STRING | — | |
| else_output3opt | STRING | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| output1 | STRING | — |
| output2 | STRING | — |
| output3 | STRING | — |
| else_output1 | STRING | — |
| else_output2 | STRING | — |
| else_output3 | STRING | — |
| tagin | BOOLEAN | — |