sizing for SDXL
Stop typing 1216x832 by hand — let this pick SDXL's bucket for you
- width
- height
- crop_w
- crop_h
- target_width
- target_height
- downscale
If you've ever generated SDXL at 768x1344 and gotten a great image, then tried 800x1350 and watched the figure grow a second left arm, this node is the thing you were missing. SDXL wasn't trained at arbitrary resolutions. It was trained on a fixed set of "bucketed" sizes - roughly a megapixel, both sides multiples of 64, aspect ratios between 1:4 and 4:1 - and on top of that it takes six conditioning values that describe the original image in the training data and how much it was cropped to fit. Generate outside that regime and the model starts improvising anatomy.
sizing_node_basic (display name "sizing for SDXL") is the simple member of the Ser-Hilary/SDXL_sizing pack, and it's the one I'd hand a beginner. You type three short strings, it hands back every number the SDXL text encoder and the empty-latent node want, all consistent with each other and plausible relative to what SDXL saw in training.
How it works
Think of it as two jobs. First, it turns your desired aspect ratio into the nearest real training bucket - so you ask for 16:9 and it gives you 1344x768 rather than a made-up 1920x1080. That's the part that stops stretched bodies, because you're generating at a size the model was actually trained on.
Second, it computes the six SDXL conditioning values. During training Stability resized each image to the bucket, then randomly cropped it, and fed the model the original size plus the crop. Setting those conditioning inputs to match your actual generation (which is what ComfyUI's defaults do) is a subtle mismatch - feeding "plausible" values instead is what makes composition behave. The numbers come from a formula: scale the hypothetical original to fit the bucket, and whatever spills over is the crop, taken from the left and top edges exactly like the SDXL paper describes.
The inputs that matter
Only three strings plus one float, and one of them you mostly never touch:
- native_res - leave it at
1024for SDXL. That's the base resolution the buckets orbit. - aspect - your desired ratio.
1:1,16:9,2:3, even a bare0.5all parse. Or type-1to just take the aspect from theoriginal_resyou give it. - original_res - the "hypothetical original image" in training. A bare number like
600means 600 on the long side;600x600means exactly that;2.0means double your generation size. - crop_extra - extra cropping as a fraction of the gen size. The author's own advice: leave it at 0, it "usually looks pretty odd."
What the outputs wire into
Seven outputs, but only two destinations. target_width and target_height are your actual generation size - feed those into Empty Latent Image. The full set of six (width, height, crop_w, crop_h, target_width, target_height) goes into CLIPTextEncodeSDXL, which has exactly those six fields waiting. Yes, width/height appear twice in that list - one pair is the conditioning "original size," the other is the generation size, and the whole point of the node is that they're no longer the same number.
The seventh output, downscale, is optional and the author will happily tell you most people don't want it - it's meant to feed an "upscale by" node if you're deliberately generating big and shrinking to match the original. Skip it.
Install
ComfyUI Manager → Custom Nodes Manager → search SDXL_sizing → Install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Ser-Hilary/SDXL_sizing
Restart ComfyUI. That's it - there's no requirements.txt, no pip packages, no model downloads. The whole pack is one pure-Python file doing arithmetic.
Where people get burned
- It's SDXL-only, on purpose. The bucket math keys off the 1024 native resolution, and the six conditioning inputs don't exist on SD 1.5 or on the newer flow-matching models. Works great on SDXL fine-tunes like Pony, Illustrious, and Juggernaut XL - not on Flux.
- "It gave me 832x832, I asked for 800x800." That's the feature. Nearest bucket, not exact request. Fight it and you're back to the stretched-body lottery.
aspectset to-1silently falls back to 1:1 if youroriginal_resis a single number rather than two dimensions. Give it800x1200and it has something to work with.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| native_res | STRING | 1024 | — |
| aspect | STRING | 1:1 | — |
| original_res | STRING | 1024x1024 | — |
| crop_extra | FLOAT | 0.0000–1 | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |
| crop_w | INT | — |
| crop_h | INT | — |
| target_width | INT | — |
| target_height | INT | — |
| downscale | FLOAT | — |