Get Random Dimensions
Get Random Dimensions rolls random sizes that stay in the model-friendly band
- width
- height
Get Random Dimensions does exactly what it says: it rolls a random width and height for you, clamped to a range you set and stepped to multiples of 16. The point is to make random variation useful instead of chaotic - because "random dimensions" in ComfyUI without guardrails is a great way to generate a 637×421 latent and watch your model cough up garbled anatomy.
Why the guardrails matter
Diffusion models have a native resolution band. Modern ones are more forgiving than the 512-only days, but you still want to stay in a sensible range and keep dimensions model-friendly - multiples of 16 are the safe convention because that's the granularity the latent space operates in (Flux-class models want multiples of 64). This node's defaults encode exactly that: min 768×768, max 1280×1280, step 16. That's the SDXL-and-Flux sweet spot - 768 sits under SDXL's native 1024, 1280 is just past it, and everything in between lands on a multiple of 16. If you're on an older SD 1.5 model you'd want to tighten the max.
Why you'd reach for it
Batch exploration. Toggle randomize, run, get a different aspect ratio every time - square, tall, wide - and use the width/height outputs to drive an Empty Latent Image or any size input downstream. It's the poor-man's random-composition sampler for when you want variety without hand-building a grid of resolutions. It's also flagged as an output node in its schema, which just means it's meant to sit at the start of a graph as a source of values.
Inputs and outputs
Five required inputs: min_width, min_height, max_width, max_height (all INT, defaults 768/768/1280/1280, each stepping by 16) and randomize (BOOLEAN, default off - your re-roll trigger). Two INT outputs: width and height, which you wire into whatever sizes your latent or image.
The honest caveat
Before you get attached: as of this writing, this node doesn't actually ship. The GitHub head deleted the GetRandomDimensions class from nodes.py - "remove unused GetRandomDimensions class" is the latest commit - while leaving its import in __init__.py, which is exactly what breaks the whole pack on startup. The schema on this page comes from when the node existed. So today you can't run it without waiting for upstream to restore it or re-adding the class yourself (it's not much code: a random pick in the min/max range snapped to 16, gated on the randomize toggle). The web/js/getRandomDimensions.js file is still in the repo, though its actual widget code is commented out - today it only registers a Material-colors settings toggle, so don't expect a front-end button either. Check the repo for a fix before you invest in it.
Install
Same pack, same steps: ComfyUI Manager → search "ComfyUI_Accessories", or:
cd ComfyUI/custom_nodes && git clone https://github.com/var1ableX/ComfyUI_Accessories
No dependencies, no models.
Common issues
The big one is the deleted class above: if the whole pack fails to import, you'll see an ImportError for custom_nodes.ComfyUI_Accessories in the console and no nodes from it will load. What randomize = off does exactly isn't verifiable while the class is gone, so treat the toggle as your re-roll and don't assume the off-state produces anything specific. And if your model needs multiples of 64, remember the step-16 outputs aren't guaranteed to satisfy that - eyeball the roll before you sample.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| min_width | INT | 768 | — |
| min_height | INT | 768 | — |
| max_width | INT | 1280 | — |
| max_height | INT | 1280 | — |
| randomize | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |