Nodes/ComfyUI Logic Support/Number Sequence Generator
ComfyUI Node

Number Sequence Generator

The node that remembers

By narusas·Created about a year ago·Updated about a year ago· 0
Number Sequence Generator
    • N
    start_number1
    end_number10
    repeat_count1
    resetno

    Almost every node in ComfyUI is pure: same inputs, same output, every time. Number Sequence Generator is the exception in this pack, and it's the reason people reach for it - it remembers. Each time the workflow runs, it returns the next number in a sequence, so run it four times and you get 1, 2, 3, 4 instead of 1, 1, 1, 1. That makes it the closest thing this pack has to a loop counter, and it's genuinely useful for batch-style workflows where you want a different value on every pass - frame numbers for video, pass numbers for an iterative upscale, a seed offset that actually increments.

    Set start_number and end_number (both 1–1000) and repeat_count (1–100), and the node walks the range, repeating each number repeat_count times before advancing, then wraps back to the start when it passes the end. With start 1, end 3, repeat 2 you get 1, 1, 2, 2, 3, 3, 1, 1… on successive executions. A reset dropdown set to "yes" wipes the counter back to the start. There's one INT output (the current number).

    How it gets away with "remembering" is worth understanding, because it's where the surprises live. The node keys its state per workflow and per parameter combo, then writes it to a JSON file inside its own folder (sequence_generator_state.json in custom_nodes/Comfyui-Logic-Support). That's how state survives a ComfyUI restart - the README advertises this as a feature, and it genuinely is. It also returns a special "always changed" flag to ComfyUI so the node always re-executes rather than caching its last result - which is the whole trick behind it advancing on every run. It even swaps the bounds for you if you set start_number above end_number.

    The trap is the flip side of that persistence. Because it has hidden state, the same graph gives different answers on consecutive runs, and if you don't know that's coming it looks like a bug. Worse, the state file survives restarts - so a sequence that "should" start at 1 might start mid-stream tomorrow morning because of what it did last night. When you want a clean slate, flip reset to "yes" (or delete that JSON file), and expect to do it more often than you'd like. For a node designed to be stateful, that's the one real gotcha.

    Install is the pack-standard one-liner:

    cd ComfyUI/custom_nodes
    git clone https://github.com/narusas/Comfyui-Logic-Support
    

    Restart ComfyUI afterward, or use ComfyUI Manager and search for "ComfyUI Logic Support." Pure Python, no dependencies, no model downloads - nothing to weigh your install down. MIT-licensed and single-author, with basically no community chatter around it. It's a niche tool, but for "give me the next number, and keep it somewhere" there isn't much else that does it this simply.

    CategoryLogic-Support

    Inputs (4)

    NameTypeDefaultDescription
    start_numberINT11–1000
    end_numberINT101–1000
    repeat_countINT11–100
    resetCOMBOno2 options: no, yes

    Outputs (1)

    NameTypeDescription
    NINT