Nodes/DJZ-ENH-system/ENH JSON Prompt Extractor
ComfyUI Node

ENH JSON Prompt Extractor

ENH_JSON for VLM Prompt Splitting

By MushroomFleet·Created about a year ago·Updated 5 months ago· 2
ENH JSON Prompt Extractor
    • output1
    • output2
    • output3
    • output4
    json_text

    Four prompts, no hand-copying

    If you run a vision language model inside ComfyUI - a local Qwen2.5VL through Ollama, say - you've probably hit the workflow where the LLM doesn't hand you one prompt but a JSON blob holding four of them: standard, closeup, wide, action. Copying each one out of a text preview and pasting it into four separate CLIP Text Encode nodes is miserable, and it breaks the moment you want to iterate. ENH_JSON is the two-second fix: feed it the LLM's JSON, get four clean STRING outputs, and wire them straight into four generation branches.

    It's the second half of the DJZ-ENH-system pack (its sibling, ZenkaiENH, loads the system prompt that makes the LLM produce that JSON in the first place). The pack ships a t2i_ENH-vision-4shot template that demands exactly four camera perspectives in one JSON response - ENH_JSON is the socket that response plugs into.

    What it actually does

    The mechanism is pure regex plus json.loads - no model, no API, no VRAM. Any LLM in the graph has conversational habits that pollute its output (the KB's llm-in-comfyui doc calls this the dirty-output failure mode), and this node is the cleanup layer. From the source it: strips markdown code fences (json, generic , and single backticks), kills trailing commas, deletes stray quote-only lines before closing braces, and trims anything after the final }. Then it parses the result and pulls four prompts via one of these shapes:

    • Direct keys - {"prompt1": "...", "prompt2": "...", "prompt3": "...", "prompt4": "..."}
    • Array of strings - {"prompts": ["...", "...", "...", "..."]}

    If nothing parses, or a slot is empty, you don't get an error - you get the author's fallback: "photo of an unimpressed white cat". Yes, that's literally in the code. It's the friendliest failure mode in ComfyUI, and also the easiest way to tell something's wrong: four cat images means your VLM ignored the format instructions.

    The inputs and outputs that matter

    There's exactly one input and four outputs, so this is a short list:

    • json_text - a multiline STRING. Wire it from your LLM node's response output, or paste the JSON if you're testing.
    • output1output4 - four STRINGs. Fan them out to four CLIP Text Encode nodes (or a switch node if you want to pick one shot per run). Per the README, output1 is the Standard Shot, output2 Closeup, output3 Wide, output4 Action.

    One honest gotcha, straight from reading the code: the README also documents an object-array format ({"prompts": [{"prompt": "..."}]}), but the code path that would unwrap it is dead - the array-of-strings branch catches it first and hands you Python's {'prompt': '...'} repr as your prompt. Stick to direct keys or a flat array and you're fine.

    Installing it

    Same as any node in the pack: in ComfyUI Manager search for DJZ-ENH-system, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/DJZ-ENH-system
    

    Then restart ComfyUI. That's the whole install. The pack's requirements.txt is literally a comment - both nodes use only Python's stdlib (logging, json, re). No model downloads, no API keys, no network calls at all. That makes it one of the more benign things you can add to your custom_nodes folder, which matters in a category (LLM/prompt nodes) that has already shipped malware once - read the comfyui-ecosystem KB doc if that's news to you.

    Common issues

    • You get four cats. The JSON didn't match any supported format. Check the raw LLM response - did your system prompt actually demand prompt1prompt4 or a prompts array? If the model wrote prose or a different schema (say a nested FLUX.2-style object), this node won't unwrap it. Tighten the format rules in your system prompt.
    • Still failing after cleanup. The cleaner handles the common slop - fences, trailing commas, stray quotes - but not every shape a chat model invents. A VLM that returns three prompts instead of four also leaves you with one cat; re-run with a lower temperature if it's flaky.
    • Object-array format spits out weird {...} text. Use flat arrays or direct keys (see above). Not a bug you can fix from the canvas.
    CategoryCustom-Nodes

    Inputs (1)

    NameTypeDefaultDescription
    json_textSTRING

    Outputs (4)

    NameTypeDescription
    output1STRING
    output2STRING
    output3STRING
    output4STRING