Nodes/Random Size/Random Size
ComfyUI Node

Random Size

Let the dice pick your resolution so your batch doesn't look like a contact sheet

By JerryOrbachJr·Created 3 years ago·Updated 2 years ago· 8
Random Size
    • width
    • height
    seed0
    preset

    If you've ever queued up a few hundred images for a dataset, a moodboard, or a "throw everything at the wall" prompt search, you know the problem: every image comes out the same shape. Same 512x512, same boring grid, and your "variety" is just the same composition in a different font. Random Size fixes that one thing. It spits out a width and a height chosen from a preset list of resolutions, so every image in your batch gets a different aspect ratio - no copy-pasting Empty Latent Image values by hand, no Python script bolted onto your workflow.

    It's a deliberately dumb node, and that's the point. All it does is hand you two integers. You wire them into an Empty Latent Image (or an Empty SD3 Latent Image, a KSampler, wherever you'd normally type resolution by hand) and the latent gets created at whatever size the node picked.

    How it works

    The node reads a YAML file of WIDTHxHEIGHT strings and uses the seed as an index into that list. Seed 0 gives you the first size in the file, seed 1 the second, and so on. Same seed, same resolution, always - it's fully deterministic. Two details worth knowing:

    • If your seed is bigger than the number of sizes in the preset, it doesn't error out - it falls back to a seeded random.choice, so you still get a reproducible pick from the list, just not a predictable one.
    • The seed widget gets ComfyUI's standard control after generate behavior. Set it to randomize and every queue run rolls a new size; set increment and it walks the list one by one, which is the cleanest way to guarantee every size in a preset gets used across a big batch.

    It also draws the whole size list on the node itself (via a tiny built-in frontend widget) and stars the one it picked, so you can see at a glance what a given seed resolves to. No API calls, no model downloads, no heavy dependencies - the only import it needs is yaml, which ComfyUI already ships.

    The inputs that matter

    There are exactly two, both on the node:

    • seed (INT, default 0) - the resolution index. Not a sampler seed.
    • preset (dropdown) - which YAML file to draw from: SD1.5, SDXL, FLUX, plus 512, 640, 768, 896, and 1024 (those are resolution-centric lists that let you vary aspect ratio while keeping a megapixel ballpark).

    The outputs are width and height, both INT. That's the whole interface.

    The one trap: the default preset is SD1.5, so if you're running SDXL or Flux and you forget the dropdown, you'll quietly get 512-ish resolutions. Pick the preset that matches the model family. The presets are centered on native resolutions - SD1.5 at 512, SDXL at 1024, FLUX in the 1024+ range - and the KB is worth remembering here: every architecture has a native resolution it was trained on, and the farther you push the extremes (the 1024 preset includes things like 512x2048), the softer the quality gets. Fine for exploring, not for final renders.

    Install

    Through ComfyUI Manager, search "Random Size" and install. Or the manual way:

    cd [path to ComfyUI]/custom_nodes
    git clone https://github.com/JerryOrbachJr/ComfyUI-RandomSize.git
    

    Restart ComfyUI. There's no requirements.txt to worry about, so this is one of the rare custom nodes that just works - no pip install, no missing-model hunt.

    Adding your own sizes

    If the bundled presets don't fit your models, drop a file named whatever.yaml into ComfyUI/custom_nodes/ComfyUI-RandomSize/sizes/custom/. First line must be sizes:, then one - WIDTHxHEIGHT per line, like - 768x512. Restart Comfy and it shows up in the preset dropdown. That's the whole feature - you can even reuse the same list for a different architecture by copying a preset file and editing the numbers.

    Where people get burned: treating the node's seed as their quality seed. It isn't. Locking the same number on Random Size and the KSampler does not reproduce an image, because here the seed only picks a resolution. If you want a fully reproducible batch, use a separate KSampler seed and let this one roam free.

    Categoryutils

    Inputs (2)

    NameTypeDefaultDescription
    seedINT00–18446744073709550000
    presetCOMBO9 options: Preset, 896.yaml, 512.yaml, SDXL.yaml, 1024.yaml, 768.yaml, +3

    Outputs (2)

    NameTypeDescription
    widthINT
    heightINT