Nodes/Dragos Scene Builder/Dragos Scene Compiler
ComfyUI Node

Dragos Scene Compiler

The node that turns your whole scene graph into one string an LLM can eat

By drago87·Created 6 months ago·Updated 14 days ago· 1
Dragos Scene Compiler
  • input_1
  • STRING

Dragos Scene Compiler is the pack's terminal node - the point where all your Dragos Variables, Objects, and Structured Builders finally become one thing you can actually do something with. Everything upstream produces PROMPT_VAR objects floating around your graph; this node gathers them, merges them into a single scene, serializes it to JSON, and hands you the result as a plain string.

It's an output node, so it earns its keep by showing you the work. In the UI you'll see the compiled JSON rendered as a readable block - the source calls it output_json_string, a hidden widget that acts as a live preview. That's genuinely useful for debugging a scene: you can see exactly what the LLM downstream is going to receive, and fix a misspelled category before it ever reaches the model.

How it works

Wire every PROMPT_VAR you care about into the node. At run time it unwraps each one, and if two inputs carry the same name, it deep-merges their dictionaries rather than overwriting - which is why a Dragos Object named character can be extended by an actions extension without nuking the character data. Once everything's collected, it serializes the scene to JSON and then does something clever for its audience: it collapses all the tabs and newlines into single spaces.

That compaction isn't cosmetic. The whole pipeline is designed to feed this JSON to an LLM, and LLMs charge by the token. A compact single-line JSON is cheaper to process and keeps semantically related values close together, which the author's comment in the code calls "improving semantic locality." Less whitespace, fewer tokens, happier context window.

The inputs that matter

  • input_1 (PROMPT_VAR) - the first thing to compile. Connect as many as you like; every one you wire in becomes part of the merged scene.

The single output, STRING, is your compact JSON scene. This is the string that the pack's README says to feed into a node that talks to an LLM backend - like ComfyUI-Z-Image-Utilities - which converts it into a proper image prompt for your model family.

A note on wiring order

The README is emphatic about this: connect the compiler's output to the first text box on the LLM node. If you're following the pack's example workflow, the compiler output goes top, and the prompt loaded by Dragos Prompt Loader goes bottom. Get the wiring backwards and your LLM will be trying to compile a system prompt into an image prompt, which is not the show you paid for.

Installing the pack

Same as every node in this pack - it ships with the rest:

cd ComfyUI/custom_nodes
git clone https://github.com/drago87/Dragos-SceneBuilder

Restart ComfyUI after, or use ComfyUI Manager and search "Dragos Scene Builder". No pip dependencies, no model files - the pack is stdlib Python plus frontend JS, and the only "model" in the whole pipeline is the optional LLM you supply separately.

Common gotchas

  • Nothing computes until you run the graph. The preview only updates on execution, so don't be surprised when a freshly-wired compiler shows an empty box.
  • Compaction is one-way for the LLM. The string you get is minified JSON; if you wanted a readable copy for yourself, look at the on-node preview, not the string output.
  • Empty inputs produce an empty scene. If you connect nothing valid, you get a nearly-empty JSON string out - no warning, just a shrug.
CategoryDragos/Scene Builder

Inputs (1)

NameTypeDefaultDescription
input_1optPROMPT_VAR

Outputs (1)

NameTypeDescription
STRINGSTRING