ComfyUI Node

Calculate Minus

A − b, but only if you feed it a fake model first

By jhj0517·Created 2 years ago·Updated 2 years ago· 44
Calculate Minus
  • model
  • minus_value
a
b10

Calculate Minus subtracts two integers and hands you the result. That is the entire job - and here's the thing you need to hear first: it's not a utility node you should be hunting for in real workflows. It's a teaching example that ships inside a GitHub template for writing your own custom nodes.

The pack is ComfyUI-CustomNodes-Template, by jhj0517 (the same person behind Whisper-WebUI and the popular finetuning-notebooks Colab trainers). It's a "Use this template →" starter repo, and the four nodes inside are commented demos meant to show you every pattern a custom node needs. Calculate Minus is the demo of required vs optional inputs and a custom model type flowing through a node.

How it works

Under the hood it's embarrassingly simple. The node calls CalculatorModel.minus(a, b), and that's a @staticmethod that just returns a - b. No GPU, no tensors, no weights. The whole "model" side is the subtle part:

  • model (required, type MY_MODEL) - you must wire this in, but the math never touches it. It exists to demonstrate that your custom type travels through the graph like any other socket. Feed it the output of the pack's (Down)Load My Model node, which is itself a fake.
  • a (required INT) - the number you subtract from.
  • b (optional INT, default 10) - the number subtracted. Notice the pattern: a is required with no default, b is optional with one. That contrast is the actual lesson.
  • Output minus_value (INT) - a - b, ready to wire anywhere an INT is accepted.

When you'd actually reach for it

Honestly? To learn, or because you forked the template. If you want subtraction in a real graph, you don't need this node's baggage - ComfyUI has core value nodes, and a dozen utility packs (rgthree, WAS, Efficiency) ship plain arithmetic. If you just need 5 - 3, type it into a widget or use a Primitive node.

Where this demo earns its keep is as a reference when you write a custom node: you can see how a function turns input widgets into a typed output, and how RETURN_TYPES/RETURN_NAMES declare ("INT",) with the name minus_value. Copy that shape, swap in real logic, done.

Installing it

Manager won't help you here - this template isn't in the ComfyUI Manager community index, which only carries jhj0517's functional packs. Clone it instead:

cd ComfyUI/custom_nodes
git clone https://github.com/jhj0517/ComfyUI-CustomNodes-Template

Restart ComfyUI. That's it - the requirements.txt is all comments and the pyproject.toml lists zero dependencies, so there's no pip install step and nothing to download.

Common issues

  • "model" input missing. The node refuses to run without a MY_MODEL wire, and the only thing that produces one is the pack's own loader node. If you just wanted math, that's your first hint this node is a demo, not a tool.
  • The bundled example workflow won't load cleanly. workflows/example-1.json ends in a Display Any (rgthree) node, so you'll get a "missing node type" error unless rgthree-comfy is installed too. Swap in any display/preview node or ignore it.
  • Don't copy the README's clone command literally. It's a template README and still says git clone https://github.com/replace-this-with-your-github-repository-url.git - that placeholder URL is exactly what you'd replace when you publish your own fork.
CategoryCustomNodesTemplate

Inputs (3)

NameTypeDefaultDescription
modelMY_MODEL
aINT
boptINT10

Outputs (1)

NameTypeDescription
minus_valueINT