Comfyui-ResolutionAndAspectRatio: Smart Prompt-Based Resolution Picker

The Comfyui-ResolutionAndAspectRatio custom node for ComfyUI converts a chosen megapixel budget and aspect ratio into precise pixel dimensions. It can automatically detect the aspect ratio from words in your prompt, or you can set it manually using a dropdown. With 23 built-in ratios and a keyword matching system, it hands your image generation a consistent, predictable resolution every time.
Dawncreatescode who also made ComfyUI-Pin-Node-Input and Comfyui-PromptHistory built this node to eliminate the guesswork when setting image resolutions in ComfyUI. It acts as a smart resolution picker that can either follow your prompt’s clues or let you pick a ratio directly. Whether you need a fixed 21:9 cinematic output or want to randomize for variety, the node adapts effortlessly.
How the node picks your aspect ratio
- Converts megapixel target and ratio to exact pixels.
- Detects aspect ratio automatically from prompt text.
- Overrides ratio by typing 16:9 or similar in prompt.
- Maps keywords like cinematic to weighted ratio pools.
- Randomizes ratio per run with seed control.
- Edits keyword rules without restarting ComfyUI.
This node is ideal for ComfyUI workflows where prompt text guides the final image dimensions. It covers anything from vertical mobile shots to expansive cinematic landscapes, removing the need to manually compute resolutions. Users can rely on fixed ratios, let the node randomize, or have keywords dictate the format.
Behind the smart detection system
The detection system follows a strict order: explicit ratios written in the prompt always take priority, then keyword matches, then the fallback dropdown. Dawncreatescode chose the Limited keyword mode as default to avoid false triggers from words like "portrait" that might describe a subject rather than a format. Users should note that the divisible_by setting may round dimensions, slightly deviating from the exact ratio for model compatibility.
"The ratio output always tells you what fired - 21:9 (from prompt), 16:9 (cinematic), 4:5 (fallback)." — Source: GitHub