ComfyUI Node

Layout Extras

Turn your boxes into a prompt string, core elements and an overlay

By Nynxz·Created 12 months ago·Updated 10 days ago· 4
Layout Extras
  • layout
  • image
  • prompt
  • elements
  • bboxes
  • width
  • height
  • overlay
  • alpha
◄line_width3►
◄fill_alpha0.18►
◄label_size16►
◄show_indextrue►
◄show_texttrue►

Layout alone is a canvas. Layout Extras is where the drawing becomes something a model can read - and it throws in the material you need to check that the model obeyed.

Wire layout in from the Layout node and you get seven outputs. It's tempting to wire the first one and ignore the rest; don't. The overlay is the whole reason this node exists as more than a compiler.

The outputs

prompt is the compiled string for whichever mode the layout is in. That's the one you feed a text encoder: Ideogram 4's caption JSON (minified, keys in trained order, with high_level_description, a style_description block and per-box entries carrying bbox on the 0–1000 grid), or FLUX 3 Image Klein's caption-then-element-table, or MOSS-Image's layout JSON. You don't have to know which - the mode decides.

elements is the same boxes in core's prompt-element format: type (obj or text), a bbox on the 0–1000 grid, a desc, and a color_palette when the box has one. This is deliberately the same shape core's Create Bounding Boxes produces, so the layout also plugs into ComfyUI's own FLUX 3 and MOSS-Image layout prompt nodes. If you've already got a workflow built around those, you can feed it from this canvas instead of rebuilding.

bboxes is a BOUNDING_BOX - the boxes in pixels, as one frame of {x, y, width, height}. And width / height are the canvas integers, which is the practical way to size your empty latent to the layout instead of retyping numbers.

overlay is the picture: your boxes drawn with line_width (3), fill_alpha (0.18), a label at label_size (16), with show_index and show_text toggles for how much is written on them. All five are advanced settings with sane defaults; the defaults are what you want for a diagnostic.

alpha is that overlay's coverage as a MASK, which is the bit people forget. Composite the overlay over a render with the alpha instead of pasting it - or take the mask and use it for something else entirely, like a debug matte.

Drawing it over your render

image is optional and changes what the overlay is. Leave it unwired and you get the boxes on a transparent background, which is right when you're checking the layout itself before spending a render on it.

Wire your VAE Decode output in and the boxes get composited straight over the generation, at the image's size. That's the useful mode: you can see at a glance whether the character ended up in the box or a foot to the left of it. Since the boxes are scaled to the image, a mismatched aspect ratio shows up immediately as boxes that don't match where you put them on the canvas - which is a bug worth catching early.

Install

Same pack as the Layout node:

comfy node install comfyui-nynxz-nodes

Or Manager, search Nynxz, or from source:

cd ComfyUI/custom_nodes
git clone https://github.com/Nynxz/ComfyUI-NynxzNodes
cd ComfyUI-NynxzNodes
pnpm install && pnpm build

Restart afterwards. No Python dependencies beyond what ComfyUI ships; the overlay is drawn with PIL and NumPy, both already there.

Common issues

Blank prompt from Extras: every box is hidden, or has zero area, or the mode's required bits are missing - Ideogram's JSON needs a description on each box to say anything useful about it.

Elements that core's nodes reject: check the element comes from elements rather than a hand-rolled dict. The 0–1000 grid is core's convention and easy to confuse with the layout's own 0–1 fractions.

Overlay cropping oddly: the overlay is resized to the first image of the batch with a Lanczos filter, so a batch of different-sized images is not supported. One image, one overlay.

CategoryNynxz/Conditioning/Layout

Inputs (7)

NameTypeDefaultDescription
layoutNYNXZ_LAYOUT—
line_widthINT31–40—
fill_alphaFLOAT0.180–1—
label_sizeINT166–96—
show_indexBOOLEANtrue—
show_textBOOLEANtrue—
imageoptIMAGEDraw the overlay over this image (a generation, say) instead of on transparent.

Outputs (7)

NameTypeDescription
promptSTRINGInto your text encoder.
elementsARRAYCore's prompt elements, for its own layout prompt nodes.
bboxesBOUNDING_BOXThe boxes in pixels.
widthINT—
heightINT—
overlayIMAGE—
alphaMASKThe overlay's coverage.