Nodes/ComfyUI-XJNodes/Integer Decrement
ComfyUI Node

Integer Decrement

The subtract twin, for when your counter goes the other way

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Integer Decrement
    • INT
    input
    decrement1

    Integer Decrement is the mirror image of the pack's Integer Increment: integer in, integer minus decrement out. That's the entire spec. It exists because when you're building graph logic - counting down through a seed ladder, walking a batch backwards, shrinking a step count per iteration - the arithmetic you want is often a subtraction, and doing it by hand-editing widgets breaks down the moment a value is wired rather than typed.

    Take the loop case. The XJNodes pack has its own loop system (Loop Start / Loop End), and any index-based loop eventually needs its counter to move. Moving it up is increment; moving it down is decrement. If your workflow processes a list from last to first, this node is the difference between a clean graph and a heap of manual rewiring.

    How it works

    It reads an INT input, subtracts the decrement value, and returns the result as an INT. Both inputs are declared with forceInput, so the source can be another node's output - a loop's index, a previous decrement's result, whatever - rather than a widget you fill in. No bounds checking, no clamping: subtracting 5 from 2 gives you −3, happily. If that matters to whatever you're feeding next, it's on you to keep the values in range.

    Inputs and outputs

    • input - the INT to decrement
    • decrement - INT, default 1, minimum 1. The amount to subtract

    Output is a single INT. For negative-side control you'll want to manage the upstream value, since decrement itself can't go below 1.

    Installing it

    Same as the rest of the pack. ComfyUI Manager → search "ComfyUI-XJNodes" → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alexjx/ComfyUI-XJNodes
    # restart ComfyUI
    

    No dependencies to install; it's a three-line function. You'll find it under XJNodes/util.

    Should you use it?

    It's a one-trick node, so the honest answer is "use it when the trick is the one you need." If you're subtracting a constant from a fixed widget value, you don't need it - just type the number. The node earns its place when the value flows from another node: counting down a batch index inside a loop, reversing a seed progression, building a descending ladder of CFG or steps. For anything more general - add or subtract, or shifting a seed by a large offset - the pack's Int Offset node is the more flexible cousin. Decrement is for when you want the intent ("count down") to be readable in the graph itself.

    CategoryXJNodes/util

    Inputs (2)

    NameTypeDefaultDescription
    inputINT
    decrementINT1

    Outputs (1)

    NameTypeDescription
    INTINT