Aspect Ratios Node
Aspect Ratios Node — ComfyUI Node Guide
- LATENT
If you've ever typed 1536 into the width field and 640 into the height field and then quietly hoped you got the ratio right, this node is for you. Aspect Ratios Node is a straight swap for ComfyUI's built-in Empty Latent Image, except instead of fumbling two number fields you pick a size and a ratio off a list, and it does the multiplication for you.
It's a ComfyUI port of sd-webui-ar, the little button row that's been in Automatic1111 forever. Same idea, translated into a node: define your favorite ratios once, then just click through them instead of doing mental math every time you want to go from square to portrait.
Why this actually matters and isn't just convenience: models care a lot about resolution. SDXL wasn't trained on arbitrary sizes - it was trained on a specific set of buckets (1024×1024, 1152×896, 1216×832, 1344×768, 1536×640, and their rotations), and going off those tends to produce the classic "why does this person have two heads" stretching artifact. Newer models like Flux and Z-Image are more forgiving about arbitrary resolutions, but they still have a native megapixel range they were trained in. The point of this node is that you set up your ratio list once, to match whatever your model actually likes, and then never think about it again.
How it works
The node has one output - LATENT - same as Empty Latent Image, so it plugs directly into your KSampler's latent input, no adapter needed. Under the hood it takes a reference dimension (size) and a ratio, computes the other dimension, and creates an empty latent at the result.
The inputs that matter:
size- the reference pixel value, default 512, steppable by 8 up to 16384. This is the number that stays fixed; the other dimension gets derived from it.standard-widthorheight. This tells the node which sidesizeactually applies to. Set it towidthand pick a 2:1 ratio withsize=1024, and you get 1024×512. Flipstandardtoheightwith the same ratio, and you get 2048×1024 instead - same ratio, opposite anchor.aspect_ratios- the ratio itself, picked from a dropdown that's populated from a config file (more below).swap_aspect_ratio- flips the ratio (1:2 becomes 2:1). Handy for going portrait↔landscape without duplicating every entry in your list.batch_size- how many empty latents to stack in the batch, same meaning as on the stock node.
The config file - this is the whole point
On first load, the node writes an aspect_ratios.txt file into ComfyUI/custom_nodes/ComfyUI_aspect_ratios/. That file is what populates the aspect_ratios dropdown, and you're meant to edit it. Each line is label, value # comment:
1:1, 1/1 # 1:1 ratio based on minimum dimension
3:2, 3/2 # classic photo ratio
16:9, 16/9 # widescreen
1.618:1, 1.618/1 # golden ratio
The label (16:9) is what shows up in the UI; the value (16/9) is what's actually computed, and it has to be numbers and a slash - nothing else. Lines starting with # are ignored. This is where you should put your model's actual trained ratios instead of leaving the defaults - if you're on SDXL, add 1152:896, 1216:832, 1344:768 as real entries rather than eyeballing them. Since ComfyUI builds a node's dropdown choices at load time, edit the file, then restart (or at least reload the node definitions) before the new ratios show up - editing it while the queue is running won't retroactively update an already-placed node.
Installing it
Easiest path: ComfyUI Manager, search for ComfyUI_aspect_ratios, install, restart. Manual route is just as simple since there's nothing to compile and no model weights involved:
cd ComfyUI/custom_nodes
git clone https://github.com/massao000/ComfyUI_aspect_ratios
Restart ComfyUI. No Python dependencies beyond what ComfyUI already ships, no downloads - it's pure logic, so if it's not showing up after a restart, it's almost certainly a folder-naming or restart issue rather than a missing package.
Common gotchas
If you type a custom ratio into aspect_ratios.txt and don't see it in the node, you edited the file but didn't restart - the dropdown is built once, not read live. And if you add a wildly asymmetric ratio (say 21:9) with a small size, remember the derived dimension still needs to make sense for your model's native resolution - this node will happily compute 2389×1024 for you, but that doesn't mean your model was trained to generate coherently at it. Pick the reference size close to what your architecture actually likes (1024 for SDXL/Flux-class models), not whatever felt convenient.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| size | INT | 51216–16384 | — |
| aspect_ratios | COMBO | 4 options: 1:1, 3:2, 4:3, 16:9 | |
| standard | COMBO | 2 options: width, height | |
| swap_aspect_ratio | COMBO | 2 options: not_swap, swap | |
| batch_size | INT | 11–4096 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |