ComfyUI Node

remove

Delete the first match of a value from your list

By StableLlama·Created about a year ago·Updated 4 days ago· 48
remove
  • list
  • value
  • list
  • success

Sometimes you don't want to remove something by position - you want to remove it by value. If your list contains the string "banana" and you want it gone, DataListRemove finds the first occurrence and deletes it. That "first occurrence" detail matters: if "banana" appears three times, this removes one, not all three.

Inputs are list and value (both any type). Outputs are the trimmed list and a success boolean. That boolean is the hidden gem here - it tells you whether the value was actually found and removed.

How it works

Mechanically it copies the list, looks for the first element equal to value, and removes it. The interesting part is what happens when the value isn't there. The node's description warns it "raises a ValueError," but the actual code catches that and returns False for success instead - your workflow keeps running, and you can decide what to do with the failure. That's friendlier than it sounds on paper.

The two outputs give you a branching point for free: if success is True, the list is one item shorter; if False, nothing matched. Wire success into an if/else node and you can handle "didn't find it" as a real case instead of letting it crash or silently pass through.

Why it's not pop

The sibling DataListPop removes by index and returns the removed item. This node removes by value and returns a success flag instead. Different tools: use pop when you know the position, use remove when you know the thing. And if you want every occurrence gone rather than just the first, that's a filter or a loop - this node only ever takes out one.

Where it fits

Practical uses: stripping a default value out of a config list before processing, removing a sentinel item that got appended upstream, or cleaning a candidate list of a known-bad entry before it reaches a sampler. It's a quiet little housekeeping node, but "quietly deleting the wrong thing" is exactly the kind of bug this makes visible via that success flag.

Installing it

Part of StableLlama's Basic data handling pack - pure Python, zero dependencies, no model files:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI afterward, or search "Basic data handling" in ComfyUI Manager and install there. Nothing in the pack has third-party requirements, so there's no dependency cleanup to do.

Common issues

The biggest surprise is the first-occurrence-only behavior - if you expected "remove all of them," you'll see leftovers. Also, value matching is exact equality, so 5 (int) is not the same as "5" (string); convert types first if that bites you. And as everywhere in this pack, feed it a data list, not a single LIST variable.

CategoryBasic/Data List

Inputs (2)

NameTypeDefaultDescription
list*
value*

Outputs (2)

NameTypeDescription
list*
successBOOLEAN