Nodes/Vevor Mask Union/Generative · Parse Blocks JSON
ComfyUI Node

Generative · Parse Blocks JSON

Turning A Model's Chatty JSON Into Blocks Your Graph Can Actually Use

By rexqin·Created about a month ago·Updated 19 days ago· 0
Generative · Parse Blocks JSON
    • blocks
    ◄analyze_response—►

    Every "let a VLM analyse the layout, then translate it, then redraw it" pipeline has the same first bottleneck: the model returns something JSON-shaped, and every node after it needs something normalised. Generative · Parse Blocks JSON is that normaliser. One string in, one list of block objects out, with every field the rest of the pack's generative nodes expect already present and defaulted.

    What a block is

    A block is one text region with everything needed to lay out a translated version of it: an ID, the source text, a box, whether there's a panel behind it, alignment, weight, size, colour, and a translation field sitting at None waiting to be filled.

    The node walks the array inside your LLM response and keeps only the items that have both a non-empty text and a four-number bbox. Everything else in the array is silently dropped - logos misread as text, prose fragments, a stray {}. Then it assigns id values 1..N in output order, and that ID is the spine of the entire pipeline: the translation prompt asks for a JSON object keyed by these numbers, and Generative · Apply Translations looks answers up by them. Reorder or re-parse and every translation lands on the wrong block.

    Defaults, straight from the source: align falls back to left and only accepts left/center/right; bold coerces to a boolean; sizePct defaults to 5; textColor defaults to #FFFFFF; containerBbox is optional and stays None if the model didn't give you one; role is whitelisted to title, bullet, label, paragraph and nulled otherwise; translation starts empty.

    Inputs and outputs

    • analyze_response - STRING, connect-only. The raw text out of your VLM node. Not the JSON object - the text.

    • blocks - JSON. That's the only output. It feeds the translate prompt builder, the apply-translations node, the generate-prompt builder, and the review path.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/rexqin/comfyui-vevor-mask-union
    # restart ComfyUI
    

    Manager → Vevor Mask Union. No pip installs; the pack declares no dependencies. Node search: "Parse Blocks".

    Where people get burned

    Invalid JSON is not an error, it's an empty list. The parser strips a markdown fence, slices first [ to last ], tries json.loads, and on failure returns [] - the same thing it returns for a genuinely empty analysis. Your graph then runs happily with zero blocks, produces an empty prompt, and generates nothing useful. If the whole translation stage seems to be ignoring you, look at the blocks output first.

    bbox is [x, y, w, h], normalised 0–1 - not [x1, y1, x2, y2]. This is the trap that quietly ruins a workflow. Downstream code treats element [2] as a width when it computes how much room a longer translation gets, and renders the box as box:x,y,w,h. Feed it corner coordinates and every width the space-budget code sees is wrong - sometimes wildly too generous, sometimes negative-room - and the char limits handed to your translator make no sense. The pack's own analyze prompt asks for [x, y, w, h] explicitly, so if you swap in your own prompt, keep that ordering.

    The first-[-to-last-] slice can glue two arrays together. A model that emits an example array and then a real one produces one unparseable blob, and per the previous point that failure is silent. Tell the model "output JSON only", and prefer a VL node that constrains decoding.

    IDs are positional, so this node must be the only thing that assigns them. Don't run it twice on different responses and expect the IDs to line up; a second, shorter analysis renumbers from 1 and everything downstream is now referring to different text.

    One block per visible text region, including the ones you don't want. Brand wordmarks, model numbers, disclaimers, the tiny legal line - they all come through as blocks. The pack's generative path carries an isLogo flag into blocks for exactly this reason; if your analyze prompt can mark brand marks, do it, because a translated VEVOR logo is a legal problem, not a typographic one.

    Categoryvevor/generative

    Inputs (1)

    NameTypeDefaultDescription
    analyze_responseSTRING—

    Outputs (1)

    NameTypeDescription
    blocksJSON—