Nodes/DJZ-Nodes/Sequential Number Generator
ComfyUI Node

Sequential Number Generator

The stateless counter that maps any seed into your range

By MushroomFleet·Created 2 years ago·Updated 5 months ago· 80
Sequential Number Generator
    • value
    • next
    start0
    end1
    seed0

    If you've ever wired a KSampler seed into a batch loop and watched every frame come out identical, you know the pain this node quietly solves. The Sequential Number Generator is a tiny utility from the DJZ-Nodes pack that turns any seed into a number inside a range you pick - deterministically, and with a next output you can feed back to advance. It's the counter you build by hand in every other workflow, except this one doesn't drift.

    How it works

    The trick is that it's stateless. It doesn't remember what it output last run. Instead it treats the seed as the position: current = start + (seed % range_size), where range_size = end - start + 1. So seed 0 with range 0–9 gives you 0, seed 5 gives you 5, seed 15 wraps around to 5 again. The second output, next, is just current + 1 that wraps back to start when it hits end.

    That wrapping is the whole game. Because every seed maps to exactly one position, you can:

    • bump the seed by one per frame to walk a sequence,
    • wire next back into seed to make an advancing counter,
    • or drive a "which prompt variant this batch item gets" selector from a single changing seed.

    The inputs that matter

    Only three, all INT:

    • start - low end of the range (default 0)
    • end - high end of the range (default 1)
    • seed - the value that picks your position (default 0)

    That's the entire API. Feed it any seed and out come value and next, both INT. value is the number to use; next is where the sequence goes from here.

    One guardrail worth knowing: if start > end, the node raises a ValueError instead of silently doing something weird. Handy for catching a swapped input, mildly annoying if you meant a descending range - just reverse the order.

    Install

    This is part of the big DJZ-Nodes pack by Drift Johnson, so you don't install it alone. ComfyUI Manager → search "DJZ-Nodes" → Install, or clone it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/DJZ-Nodes
    cd DJZ-Nodes
    pip install -r requirements.txt
    

    Then restart ComfyUI. A heads-up: that requirements.txt pulls some genuinely heavy stuff (librosa, numba, trimesh, moderngl) that exists for other nodes in the 75+-node pack. This one only needs plain Python - the bloat is the pack's, not this node's.

    Common issues

    The only real footgun is expecting persistence. Because the node is stateless, it computes the same number every time for the same seed - you must feed it a changing seed (or loop next back in) to get a sequence. People burn a few minutes wondering why their "counter" doesn't count. It's not a bug; the seed is the counter.

    Also, this pack is a bit of a lone wolf on Reddit - thin community chatter, and the repo even briefly 404'd back in June 2025 before coming back. If a DJZ link ever looks dead, it's usually transient, not abandoned.

    Categorynumber operations

    Inputs (3)

    NameTypeDefaultDescription
    startINT0-2147483648–2147483647
    endINT1-2147483648–2147483647
    seedINT00–18446744073709550000

    Outputs (2)

    NameTypeDescription
    valueINT
    nextINT