Nodes/ComfyUI_StringOps/范围内随机数🐠meeeyo.com
ComfyUI Node

范围内随机数🐠meeeyo.com

A random number node that re-rolls every single run — that's the point

By MeeeyoAI·Created 2 years ago·Updated about a year ago· 209
范围内随机数🐠meeeyo.com
  • any
  • INT
  • STRING
range_str0-10

GetRandomIntegerInRange is the simplest node in this pack and one of the most immediately useful: you type a range like 0-10, it hands you back a random integer in that range - as both an INT and a STRING output. That's it. But the detail that makes it worth a paragraph of its own is when it rolls.

The node defines IS_CHANGED() to return NaN, so ComfyUI treats it as changed on every queue execution. In practice that means it re-rolls the number every time you hit Run, even if you didn't touch any input. That's the opposite of ComfyUI's built-in seed nodes, which remember their last value until you deliberately change the input. Here, randomness is the default state of the world.

That's exactly what you want for most of its jobs: a fresh random seed per run (feed the INT into a KSampler seed port), a random CFG or denoise strength for variation batches, a random picker to drive a Switch node, or a seed for any of the string-randomization nodes in this pack. The STRING output is a courtesy for logging or for text-based workflows where you need the number as a label.

The input

  • range_str - a string like 0-10 (default). Inclusive on both ends: 0-10 can return 0 and can return 10. The node tolerates a reversed range (10-0 becomes 0-10), which is friendly but easy to forget is happening.

There's also an optional wildcard input (any) that accepts any type. It does nothing functionally - the author uses it as a way to force execution ordering in the graph, so if you see it in a workflow, that's all it's for.

The gotchas

  • No dash in the range (e.g. 10) raises a parse error and the node returns (0, "0") silently - no error message, just a quiet zero. So a typo looks like "random number happened to be 0."
  • Same silent-zero behavior on any non-numeric input. If a workflow keeps producing 0 seeds, check the range string before anything else.
  • Because it re-rolls every run, it's a poor fit for anything you need to reproduce. If you want a stable seed that only changes when you ask, use ComfyUI's built-in seed behavior instead - this node is deliberately the opposite.

Installing

It comes with the MeeeyoAI/ComfyUI_StringOps pack. Manager users: search ComfyUI_StringOps and install. Everyone else:

cd ComfyUI/custom_nodes
git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git

Restart ComfyUI and look under the "Meeeyo/Number" menu. No model downloads; the pack's dependencies (numpy, torch, Pillow, requests and a few others) are things a working ComfyUI already has. Note the README's own suggestion: the timestamp node GetCurrentTime in the same pack is the other "random per run" seed source, if you want a seed that looks like a clock reading instead.

It's a three-line node doing a three-line job, but "give me a random integer, now, every time" is a surprisingly common request in this ecosystem. When that's the ask, this is the one.

CategoryMeeeyo/Number

Inputs (2)

NameTypeDefaultDescription
range_strSTRING0-10
anyopt*

Outputs (2)

NameTypeDescription
INTINT
STRINGSTRING