Mie Loop Body In ๐
Mark the start of a loop body and carry a value in
- loop_ctx
- anchor
- loop_ctx
- anchor
ComfyUI has no built-in way to loop - no "for each" construct, no repeat block. Packs that need iteration build their own, and MieNodes' answer is a small family of loop nodes threaded together by a context object. MieLoopBodyIn is the node that marks where a single pass through the loop begins.
It's part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under ๐ Loop.
Why a loop system exists at all
If you want to run the same sub-graph over every image in a folder, every caption in a set, or every frame of a clip, your options in vanilla ComfyUI are grim: duplicate the nodes N times, or reach for a third-party loop pack. Given MieNodes' roots in dataset processing - captioning, converting, deduping whole folders - a loop is the obvious thing to want. This subsystem is the author's take on it.
The way these systems work is by passing a context object from node to node. Here it's typed MIE_LOOP_CTX, and because it's a custom type it only connects to other Mie loop nodes - which is your signal that these are a matched set, meant to be used together, not mixed with loop nodes from another pack.
How it works
MieLoopBodyIn takes the loop context in and passes it back out, marking the top of the loop body - the point after which the per-iteration work happens. Its extra trick is the optional anchor: any value you wire in comes straight back out the anchor output, untouched.
That passthrough looks pointless until you understand ComfyUI's execution model. The graph doesn't run left to right; it runs by dependency. An anchor is the standard way loop and utility packs force ordering - by making a node downstream depend on the anchor output, you guarantee it runs inside the loop body at the right moment rather than whenever ComfyUI feels like it. So anchor is both "carry this value into the body" and "pin this node's execution to here."
The inputs and outputs that matter
loop_ctx(MIE_LOOP_CTX, required) - the loop context, from the loop's start/driver node or the previous loop node. Thread it through.anchor(any, optional) - a value to carry into the body and/or an ordering handle. Passed through unchanged.loop_ctx(output) - pass onward into the body and eventually to MieLoopBodyOut.anchor(output) - your value back out.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model download. Nodes appear under ๐ MieNodes.
Common issues & troubleshooting
It only connects to other Mie loop nodes. The MIE_LOOP_CTX type is deliberately incompatible with everything else, so you can't feed it a generic value or wire it into a foreign loop pack. The context has to originate from this subsystem's own start node and flow through MieLoopBodyOut to close the pass.
Something in the body runs at the wrong time. That's exactly what anchor is for. Route the value your body needs through the anchor, and make the body's first real node depend on the anchor output, so execution order is nailed down instead of left to the scheduler.
Docs are thin. The pack's README doesn't cover the loop nodes in depth, so expect to learn this subsystem by wiring it up and watching what runs. Start small - a two-iteration loop with a preview inside - before you build something elaborate on top of it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ | |
| anchoropt | * | โ |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
| anchor | * | โ |