ComfyUI Node

TensorToList

Drop a tensor into plain Python so you can finally see it

By TashaSkyUp·Created about a year ago·Updated about a year ago· 1
TensorToList
  • input_data
  • LIST

Tensors are opaque until you look inside them, and ComfyUI isn't built for peeking. TensorToList converts a TORCH_TENSOR to a plain Python list - nested lists, matching the tensor's shape - so you can see the actual numbers in the node's output, or feed them onward to something that expects ordinary data. It's the "show me the values" node, and it's the simplest thing in this pack.

It's part of EternalKernel PyTorch Nodes (TashaSkyUp), the raw-PyTorch-in-ComfyUI pack. In a graph full of invisible tensor plumbing, this is one of the few nodes that turns a tensor into something a human can read.

How it works

The mechanism is one call: tensor.tolist(), which is PyTorch's built-in conversion. A (2, 3) float tensor becomes a list of two lists of three floats. An integer tensor becomes a list of ints. A scalar tensor becomes a single value. There's no float rounding, no precision trimming - you get whatever's in memory, and for float32 that can be long, ugly decimals. If you're checking whether training actually lowered the loss, you'll probably want to eyeball the first value and ignore the rest.

The LIST output type is the pack's generic Python-list port. It's most useful as a debugging aid (hook it to a node that shows output values) and as a bridge to PlotSeriesString-style consumers - though note PlotSeriesString's input is a STRING field, so you'll be copy-pasting the numbers either way.

Inputs and outputs

  • input_data (required TORCH_TENSOR) - the tensor to unpack.
  • Output: LIST - the tensor as nested Python lists.

Installing it

Shared with the whole pack:

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

Restart ComfyUI and it's under ETK/pytorch - or ComfyUI Manager, searching "EternalKernel PyTorch Nodes".

Troubleshooting

Honestly, not much goes wrong here. The main gotcha is scale: converting a big tensor (say (60000, 784) of floats) to a Python list is slow and produces a wall of text that chokes the node preview and makes your browser sad. Slice it down first with SliceTensor - a (5, 784) slice converts fine. Also tolist() requires CPU or works on CUDA tensors but copies them over, so huge GPU tensors are doubly expensive. And if the tensor has requires_grad on (which TensorsToDataset likes to set), you might see gradient-tracking warnings in logs - harmless for a read-only conversion. As with the rest of this pack, the global type-checking patch means bad inputs fail weird rather than clearly, so feed it a real tensor and it'll behave.

CategoryETK/pytorch

Inputs (1)

NameTypeDefaultDescription
input_dataTORCH_TENSOR

Outputs (1)

NameTypeDescription
LISTLIST