Nodes/Latent Tools/LTReshapeLatent
ComfyUI Node

LTReshapeLatent

Reshape a latent like a NumPy array — know what you're signing up for

By Machines-of-Disruption·Created about a year ago·Updated 8 months ago· 27
LTReshapeLatent
  • input
  • LATENT
strictfalse
dim00
dim10
dim20
dim31
dim44
dim5128
dim6128

This is the "I know what I'm doing" node of the pack, and the author knows it. LTReshapeLatent does not resize anything. It reshapes the raw latent tensor the way you'd call .reshape() on a NumPy array - same numbers, new arrangement. If that sentence didn't make you pause, read on before you use it.

What it does

One LATENT in, one LATENT out, with a new tensor shape. The inputs are input (the LATENT), a strict boolean, and seven dimension fields, dim0 through dim6:

  • strict - tooltip from the author: "Don't allow total size mismatch between input and output tensors." On, it refuses to run if the number of elements doesn't match. Off, it pads or truncates to make it fit.
  • dim0–dim6 - target dimensions. Any dim set to 0 is ignored; the output gets reshaped to the product of the nonzero ones. Defaults are 0, 0, 0, 1, 4, 128, 128.

The mechanism

The tensor is flattened to one long list, then reshaped to the dims you gave it. In non-strict mode, if your target needs more elements than the input has, it repeats values to fill the gap; if it needs fewer, it truncates. Strict mode just raises an error on any mismatch instead of silently bending the data.

Why those defaults? (1, 4, 128, 128) is exactly a standard SD 1.5/SDXL latent for a 1024x1024 image: batch of 1, 4 channels, at 8x downscale. The defaults are "a normal latent," which tells you the author's mental model - most of the time you're only touching a dimension or two.

The warning that matters

Reshaping reinterprets the element layout. A 4-channel latent squashed down to 1 channel is not "the same image in one channel" - it's the same sequence of numbers shoved into a different arrangement, and decoding it will produce scrambled, abstract garbage. Same with swapping height and width: the image isn't rotated, it's permuted. The numbers are all still there; the meaning is gone.

So what's the intended use? The README shows the one that makes sense: make one latent match the shape of another so two tensors line up downstream (blending, concatenating, feeding a node that insists on a specific layout). Pair it with the pack's sibling LTLatentToShape, which just reads a latent and outputs its dimensions - use that to see what shape you're aiming for, then reshape to meet it.

Honest advice: if you're a beginner who thinks you need this, you probably don't. A shape mismatch usually means you should fix the sizes upstream - resize the image, use the right VAE, generate at the right resolution - rather than coerce the tensor. This is a scalpel, and it will happily cut you. When a node says "shape mismatch," reaching for a raw reshape to shut it up is how you get pretty noise and an hour of debugging.

Installing it

latent-tools is a small MIT-licensed pack by xl0 (Alexey Zaytsev), published on the Comfy Registry. Easiest path: ComfyUI Manager → Install Custom Nodes → search "Latent Tools" and install, then restart ComfyUI. Manual path:

cd ComfyUI/custom_nodes
git clone https://github.com/xl0/latent-tools

Then restart ComfyUI; the node sits under LatentTools. Only dependency is lovely-tensors, no model downloads. Niche pack from a single author - appropriate for a tool this sharp.

CategoryLatentTools

Inputs (9)

NameTypeDefaultDescription
inputLATENT
strictBOOLEANfalseDon't allow total size mismatch between input and output tensors
dim0INT00–4096
dim1INT00–4096
dim2INT00–4096
dim3INT10–4096
dim4INT40–4096
dim5INT1280–4096
dim6INT1280–4096

Outputs (1)

NameTypeDescription
LATENTLATENT