ComfyUI Node

Tag

Slap a label on any data, filter it back out later

By Trung0246·Created 3 years ago·Updated about a year ago· 137
Tag
  • data_in
  • data_out
ops_mode
neg_mode
tag_mode
tagtag

ComfyUI is great at moving data and terrible at remembering what a piece of data is for. Tag is the "sticky note" you never knew you wanted: it lets you label any value flowing through the graph, then filter on that label somewhere downstream. Wire a thing in, give it a tag, and later nodes can say "give me only the stuff tagged keep" and get exactly that.

It's part of Trung0246's ComfyUI-0246 pack - one developer's "random nodes I made to solve my struggle with ComfyUI," added in a March 2024 update. Tag is squarely aimed at the pack's own data-management family: it's the natural companion to Cloud, Junction, Highway and the Loop/Hold trio, all of which shuffle data around in ways that quickly become hard to track by eye.

How it works

Under the hood, Tag wraps whatever you feed it in a thin, transparent wrapper that carries two pieces of metadata: the tag name and the node ID that applied it. The wrapper is invisible to every other node - a tagged LATENT or STRING behaves exactly like an untagged one - so the tag rides along without getting in the way.

The ops_mode dropdown is what you'll live in:

  • apply - attach the tag to the incoming data and pass it through. This is the tagging step.
  • check - pass through only items that have this tag. The filter step.
  • remove - strip the tag off matching items (and if that was the item's last tag, unwrap it back to plain data).
  • clear - dump all tags and unwrap everything that matches.

Then the fine print: tag is the label itself (default "tag"), tag_mode chooses exact match or regex, and neg_mode flips the whole thing into "NOT" mode - return everything that does not have the tag. data_in takes any type and data_out passes it along, so you can chain Tag nodes or run the output straight into whatever needs the filtered result.

One honest caveat: tags live only for the run. Nothing is written into your PNG metadata or saved to disk - it's all in-memory labels for the duration of the workflow. If you want the tag to survive a restart, that's a different feature in a different pack.

Where it earns its keep

The realistic use is inside loops and batch pipelines. Tag each iteration's output as it's produced, then have a downstream node check for the ones you actually care about - say, marking certain images as "selected" while a batch keeps generating. It also shines for keeping one wire busy with mixed data: instead of three separate primitives feeding three different places, tag each kind of data and let consumers filter by tag.

That said, if your need is just "pick between two values," a primitive switch is simpler and more stable. Tag pays off when you're managing many tagged values across a complex graph - which is exactly the situation that pushed the author to build it.

Installing it

Same pack as the rest: in ComfyUI Manager, search "ComfyUI-0246" and install, or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Trung0246/ComfyUI-0246

Restart ComfyUI and you'll find the nodes under the 0246 category. No models to download - pure code. Dependencies are light (wrapt, natsort, wat-inspector), and the pack tries to auto-install the first two at load if they're missing.

Troubleshooting

Tag is one of the simpler nodes in the pack, so it's comparatively robust - the fragile stuff in ComfyUI-0246 is the control-flow family (Loop, Switch), which rewrites ComfyUI internals and can break on updates. Tag just wraps and unwraps data, so it tends to keep working. The realistic friction is conceptual: if your tagged data comes back "missing," nine times out of ten it's because a clear or remove upstream stripped the tag before your check ran, or the tag didn't match because you were in exact mode and typed something slightly different. When in doubt, regex mode with a short substring is the forgiving option.

Category0246

Inputs (5)

NameTypeDefaultDescription
data_in*
ops_modeCOMBO4 options: apply, check, remove, clear
neg_modeBOOLEAN
tag_modeCOMBO2 options: exact, regex
tagSTRINGtag

Outputs (1)

NameTypeDescription
data_out*