Nodes/ComfyUI-Calculation/Create QR Code
ComfyUI Node

Create QR Code

A QR Code Straight Out of Your Graph (No Website, No API Key)

By Limitex·Created 3 years ago·Updated 2 years ago· 0
Create QR Code
    • IMAGE
    content
    errorL
    version3
    modebinary
    encodingiso-8859-1
    scale5
    module_color_R0
    module_color_G0
    module_color_B0
    module_color_A255
    background_R255
    background_G255
    background_B255
    background_A255
    quiet_zone4

    Create QR Code does exactly what the name says: you type a URL or any text, and it hands back a QR code as a ComfyUI IMAGE tensor. No website, no API, no API key - it's all generated locally in the graph. The immediate question is why you'd want that inside ComfyUI at all, and the honest answer is QR art.

    The "QR Monster" style - feeding a QR code as a ControlNet condition (brightness/pattern based) so the model draws art over it while keeping it scannable - was one of the highest-engaged ControlNet techniques of the SDXL era. If you're building one of those workflows, this node is the cleanest way to generate the condition image without leaving the graph or pasting a QR from a random website. Fair warning: as of this writing there's no working QR ControlNet for post-Flux models - QR Monster never got ported past SDXL - so this pairs with an SD 1.5 or SDXL pass, or with plain compositing a scannable code onto a poster. It's also just handy for embedding a real code into marketing-style generations.

    How it works

    Under the hood it uses the pyqrcode library to build the code, renders it to PNG in memory (pypng), loads that with PIL, and converts it to a float tensor via torchvision's ToTensor(). The heavy machinery - PIL, torchvision - already ships with ComfyUI, so the pack only needs two tiny pure-Python packages to add.

    The inputs that matter

    Only content is required - your URL or text. Everything else has a sane default, and three of them are worth touching:

    • error (L/M/Q/H) - the error-correction level. The default is L, which is the weakest. For QR art, where ControlNet is going to smear the pattern, bump it to Q or H or your code will stop scanning entirely. L recovers ~7% of damage, Q ~25%, H ~30%.
    • scale - pixels per module. Default 5 produces a small image; raise it if you're feeding a big canvas.
    • quiet_zone - the white margin scanners need around the code. Default 4 modules is the spec; leave it alone unless you genuinely don't care about scanning.

    The color inputs (module + background, each with RGBA) let you pre-tint the code, and version 1–40 trades density for capacity - keep the default and let pyqrcode pick. mode defaults to binary, which is right for URLs.

    Wiring the output

    One output: IMAGE. Straight into a preview, an image-scale node, a LatentComposite to drop it on a canvas, or straight into a ControlNet preprocessor as the condition. One gotcha from the implementation: because it's built with ToTensor(), the tensor comes out channel-first with no batch dimension, which isn't the BHWC shape most ComfyUI nodes expect. If a downstream node throws a shape error, run the output through an image-resize/convert node first - that normalizes it.

    How to install

    Same as the rest of the pack. In ComfyUI Manager, search ComfyUI-Calculation and install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Limitex/ComfyUI-Calculation
    

    Then restart. Manager handles the pip deps for you; if you cloned manually, pip install -r requirements.txt (it's just pyqrcode and pypng). No models to download.

    Common issues & troubleshooting

    • Code won't scan. First suspect is error-correction level L - raise it. Second is quiet_zone set to 0, or a white-on-dark color inversion. Always test with your phone before committing to the workflow.
    • Shape errors downstream. That's the channel-first tensor above; normalize it through a resize node.
    • Content too long for the version. pyqrcode will bump the version automatically, so this rarely bites unless you force a tiny version with a huge string.

    If you're making QR art, remember the ControlNet needs a high control weight and a strong aesthetic prompt - the QR holds the structure, the model supplies the art.

    CategoryCalculation

    Inputs (15)

    NameTypeDefaultDescription
    contentSTRING
    erroroptCOMBOL4 options: L, M, Q, H
    versionoptINT31–40
    modeoptCOMBObinary4 options: numeric, alphanumeric, kanji, binary
    encodingoptSTRINGiso-8859-1
    scaleoptINT5
    module_color_RoptINT00–255
    module_color_GoptINT00–255
    module_color_BoptINT00–255
    module_color_AoptINT2550–255
    background_RoptINT2550–255
    background_GoptINT2550–255
    background_BoptINT2550–255
    background_AoptINT2550–255
    quiet_zoneoptINT4

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE