Nodes/ComfyUI-XJNodes/Wrap as List (XJ)
ComfyUI Node

Wrap as List (XJ)

The one-line fix when ComfyUI wants a list and you've got a single value

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Wrap as List (XJ)
  • value
  • list

ComfyUI has a weird relationship with lists, and it's not your fault if you've never thought about it. Under the hood, nearly every node output gets wrapped as a single-element list [value], and most consumers quietly unwrap it for you. The trouble starts when you build a workflow where a node genuinely needs a list as input - like the loop nodes and list manipulators in ComfyUI-XJNodes - and all you have is one number, one image, or one string. That's exactly when you reach for Wrap as List (XJ).

It does precisely what the name says: it takes any single value and wraps it in a one-element list. value goes in, list comes out. The author's own docstring says it's "useful for converting single items to lists before passing to loop nodes," and that's the honest use case. Think of it as the adapter between "I have a thing" and "I have a list of things, of length one."

Why this node exists at all

The pack's loop system (XJLoopStart/XJLoopEnd) has to fight ComfyUI's list semantics to keep lists intact across iterations - the docs describe a genuine bug in ComfyUI's subgraph link resolution that unwraps list outputs one time too many, and the workarounds to compensate. In that world, a node that explicitly marks its output as a list (OUTPUT_IS_LIST = True) is a building block, not a convenience. You'd also use it to normalize data before any node that expects INPUT_IS_LIST - a list accumulator, an append node, a list filter. Same idea: hand it a clean, declared list instead of hoping ComfyUI's auto-wrapping does what you meant.

The whole interface

It's one input and one output, both typed as a wildcard (*) so they accept anything:

  • value - the single item to wrap. Any type.
  • list - the same item, now inside a list.

That wildcard input is worth a sentence because it's the entire reason the node is usable: since the type is *, you can connect a number, an image tensor, a string, or a conditioning - no type mismatch errors, no conversions. It just wraps whatever shows up.

The paired inverse lives in the same pack: Unwrap from List (XJ) pulls the single value back out for nodes that can't handle lists. Use them as bookends around any list-only segment of your graph.

Installing it

The pack is ComfyUI-XJNodes by alexjx. Easiest route is ComfyUI Manager - search "XJNodes" - or the manual clone:

cd ComfyUI/custom_nodes/
git clone https://github.com/alexjx/ComfyUI-XJNodes.git

Restart ComfyUI afterward. This one has no dependencies beyond ComfyUI itself: the pack's requirements.txt is empty and the node is pure Python - a str subclass wildcard type plus a function that returns ([value],). Nothing to download, nothing to break.

Honest notes

This is a utility node, not a star. If you've never hit a "this node needs a list input" error, you may never need it - and that's fine. Its sibling Unwrap from List (XJ) is arguably the more interesting half of the pair, because unwrapping is where the double-list weirdness bites. Where people do get tripped up with this node: it wraps unconditionally, so don't feed it a value that's already a list expecting it to stay flat - you'd get a list containing a list. If you find yourself wrapping a real multi-item list, you wanted a different operation entirely.

One more thing worth knowing: the pack's README calls itself "primarily for personal use and experimentation," so treat it as a well-intentioned hobby pack - the code is small and readable (which is good for trust), but don't expect a big support community or rapid updates behind it.

CategoryXJNodes/Lists

Inputs (1)

NameTypeDefaultDescription
value*

Outputs (1)

NameTypeDescription
list*