Nodes/ComfyUI-JDCN/JDCN_SwapInputs
ComfyUI Node

JDCN_SwapInputs

Flip any two wires without rewiring your graph

By daxcayΒ·Created 2 years agoΒ·Updated about a year agoΒ· 159
JDCN_SwapInputs
  • inputA
  • inputB
  • outputA
  • outputB
β—„SwapITfalseβ–Ί

JDCN_SwapInputs is the node equivalent of a two-way switch: it takes two values, and based on a boolean, either passes them through or hands them back swapped. That's it. But "that's it" is genuinely useful in ComfyUI, where A/B testing means rebuilding or re-wiring half your graph.

What it's for

Say you want to compare two checkpoints, two prompts, two LoRAs, or two reference images on the same seed. Normally you'd build two identical branches or manually swap which output you've wired. This node lets you keep both candidates wired in and flip one boolean - or, better, wire that boolean to another part of your workflow so the swap happens per run without you touching the canvas.

It accepts anything, because its inputs are typed as * (Comfy's any-type). inputA and inputB can be images, model objects, strings, latents, whatever - the node never inspects the values. When SwapIT is on, outputA carries whatever came into inputB and vice versa. When it's off, everything passes straight through.

The inputs that matter

  • inputA / inputB - the two values to optionally swap. Any type.
  • SwapIT - the boolean that decides. This is the only input you'll actually touch.

The two outputs, outputA and outputB, are what you wire onward. Keep the correspondence straight: with SwapIT off, outputA == inputA; flip it and outputA becomes inputB.

A realistic example

Compare two prompts on a fixed seed: wire prompt A and prompt B into the node, then feed its outputA into your positive conditioning. Toggle SwapIT and you get prompt B without touching the CLIP text encode branch. Add a JDCN_BatchCounter or a random boolean upstream and the swap happens automatically on each queue run - decent poor-man's grid search.

The same trick works for toggling between an upscale pass and a raw pass, or between two checkpoints, since * inputs accept model objects without complaint.

Installing it

It's part of ComfyUI-JDCN. Install via ComfyUI Manager (search JDCN, install ComfyUI-JDCN, restart), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN.git
cd ComfyUI-JDCN
pip install -r requirements.txt

Restart, and it shows up under the πŸ”΅ JDCN πŸ”΅ category. Only dependency is piexif; no model downloads.

Common issues

The usual beginner trip is expecting this to toggle state - it doesn't, it's stateless pass-through. Each queue run evaluates the current SwapIT value; if you want it to alternate between runs, you have to drive that boolean from something that changes, like a counter. Also, because the inputs are any-typed, ComfyUI won't warn you if you connect mismatched things - garbage in, garbage out, swapped.

One more honest note: don't expect a visual "A/B" display. It's a plain two-output passthrough. If you want labels and a cleaner UI for comparing candidates, this pack isn't that - but for a dead-simple conditional swap, it's hard to beat.

CategoryπŸ”΅ JDCN πŸ”΅

Inputs (3)

NameTypeDefaultDescription
inputA*β€”
inputB*β€”
SwapITBOOLEANfalseβ€”

Outputs (2)

NameTypeDescription
outputA*β€”
outputB*β€”