Nodes/comfyui-jsonprompt/JSON → Prompt Builder
ComfyUI Node

JSON → Prompt Builder

It Doesn't Call Any API — It Just Turns Your JSON Into a Prompt

By wwzhifeng·Created 10 months ago·Updated 10 months ago· 33
JSON → Prompt Builder
    • prompt
    json_text{ "prompt": "example" }

    The name of this pack is half a lie, and it's the good half. comfyui-jsonprompt doesn't call Gemini, OpenAI, Sora, or anyone else - no API, no key, no network. The JSON Prompt Builder is one node with one input, and all it does is flatten a structured JSON string into a plain, comma-joined prompt. Which, in the current model era, is more useful than it sounds.

    Here's the context. Models like Flux 2's Klein, Google's Nano Banana (Gemini), and Sora don't read prompts like CLIP tag soup - they read them like a chat message, and people have found that structured JSON prompting reduces ambiguity and concept bleed. Ideogram 4 went further and was trained exclusively on structured JSON captions. So there's real value in drafting a prompt as JSON: keys like subject, background, lighting keep each idea separate. But every classic ComfyUI checkpoint you already own chokes on { and " - and you still have to paste something into an API playground. That's the gap this node sits in: draft structured, ship flat.

    How it works

    The whole thing is ~50 lines of Python with zero dependencies. It runs json.loads() on your text, then recursively walks the result and collects only the values - every key is dropped. Strings and numbers are kept, lists are flattened, and nested dicts contribute their leaf values. Everything gets stripped, emptied strings vanish, and the survivors are joined with ", ". No magic, no LLM involved.

    The inputs that matter

    There's exactly one:

    • json_text - your JSON string, multiline, defaults to {"prompt": "example"}.

    And one output: prompt, a STRING. Wire it into any text input - a CLIP Text Encode, a text box for an API-based workflow, whatever.

    That's the whole surface. The README mentions a joiner input for picking your separator, but the shipped code doesn't have one - the comma is welded in. Another one of those readme-vs-source situations; trust the code.

    Where people get burned

    Nothing here will crash your graph, which is itself the trap. The node never errors out - it returns a string. Specifically:

    • Invalid JSON → you get JSON 解析错误: <error> (a Chinese error message) as your prompt output. The graph keeps running, and that garbage string flows silently downstream. If your images suddenly contain a prompt that reads like a parser complaint, check your JSON, not your workflow.
    • Keys are dropped. {"subject": "a cat", "background": "beach at sunset"} becomes a cat, beach at sunset - exactly what you want for tag models. But {"elements": {"color": "red"}} loses the label and you get just red. If you need to preserve structure for an LLM-based model, this is the wrong tool - it flattens on purpose. In particular, don't run Ideogram-4-style boxed JSON through here; that model needs the boxes to stay.
    • Empty or whitespace-only input → silently becomes the string photo.

    Installing it

    Via ComfyUI Manager, search the pack title "comfyui-jsonprompt" (or paste the repo URL), or just:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wwzhifeng/comfyui-jsonprompt.git
    

    Then restart ComfyUI. That's it - no requirements.txt, no model downloads, no torch imports. The node lives under the ZhiFeng/JSON category as "JSON → Prompt Builder".

    Verdict

    It's a one-trick utility with a couple of sharp edges, and honestly, most people who need this workflow would write the same 10 lines themselves. But if you already have an LLM drafting structured prompts and you want them shoved, flat, into a text box without thinking - or you're pasting into Nano Banana and don't want braces in your prompt - it does the job with nothing to install. Just remember it's a flattener, not a formatter: you give it structure, you get back tag soup.

    CategoryZhiFeng/JSON

    Inputs (1)

    NameTypeDefaultDescription
    json_textSTRING{ "prompt": "example" }

    Outputs (1)

    NameTypeDescription
    promptSTRING