Nodes/ComfyUI Prompt Builder/Json Prompt Builder
ComfyUI Node

Json Prompt Builder

Structured prompts for LLM-encoded models, without hand-typing JSON

By AIMovieStudio·Created 8 months ago·Updated 7 months ago· 2
Json Prompt Builder
    • json_string

    If you've been poking at any of the newer LLM-encoded models - Flux 2 Klein, Anima, Z-Image, the Qwen-based crowd - you've probably seen the trick: feed them a structured JSON prompt and the model keeps subjects, attributes and composition from bleeding into each other. The catch is that hand-typing JSON as a prompt is miserable, and most people give up after the second unclosed brace. Json Prompt Builder exists to generate that JSON for you from the same named variables the rest of this pack uses.

    It's the sibling of Text Prompt Builder, with the template removed: instead of weaving variables into a sentence, it dumps them into a JSON object where each variable's name becomes a key and its text becomes the value.

    How it works

    Connect Text Prompt Nodes to the dynamic variable_1, variable_2, … inputs - same auto-expanding slots as its text sibling. On run, the node collects everything, uses each variable's var_name as the JSON key and its text as the value, and hands back a pretty-printed JSON string:

    {
      "subject": "a confident Shiba Inu",
      "style": "wearing a superhero cape"
    }
    

    The output is a single json_string (type STRING). Note the "string" part: this doesn't produce a structured JSON data type - it's a formatted text blob you feed into the model's prompt input, which is exactly what these encoders want. Wire it wherever you'd wire a prompt string.

    Two implementation details are worth knowing because they shape what you can connect. Variables are ordered by slot number, so keys come out in a predictable order. And if you connect a raw string instead of a Text Prompt Node, it's not dropped - it becomes a key named after the slot (variable_1, variable_2…), which is ugly but functional. Connect a plain string and you'll get "variable_1": "your text" as a key. For clean keys, feed it Text Prompt Nodes.

    Should you bother?

    Honest answer: only sometimes. The people who made JSON prompting popular are the first to tell you a well-structured paragraph does the same job - JSON is a way to give an LLM clean field separation, not a magic syntax the model parses. If you have one subject and three attributes, a sentence is fine and this node is ceremony. But when you've got three characters, each with their own pose, clothing and lighting, and plain prose keeps gluing their attributes together, the JSON structure genuinely helps - and this is the least painful way to build it, because each field stays an editable, swappable node.

    Installing it

    It's part of ComfyUI Prompt Builder, so the install is shared with the whole pack. ComfyUI Manager: search "ComfyUI Prompt Builder", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aimoviestudio/comfyui-promptbuilder
    

    Restart ComfyUI and you're done - no dependencies, no models to download. The whole pack is a few hundred lines of pure Python plus one JS file, so it can't drag your environment into dependency hell the way heavier custom nodes can.

    One tip before you go: name your Text Prompt Nodes with the exact keys you want in the JSON - composition, lighting, camera. That's what ships in the output, and it's what the model reads.

    CategoryPromptBuilder

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    json_stringSTRING