Nodes/WebUI Monaco Prompt/WebuiMonacoPromptTemplate
ComfyUI Node

WebuiMonacoPromptTemplate

The node that assembles your prompt from parts — like wildcards, but inside the graph

By Taremin·Created 4 years ago·Updated about a month ago· 29
WebuiMonacoPromptTemplate
    • contents
    • json
    source_templates
    entry_points
    seed0

    This is the node that actually writes your prompt. The rest of the WebUI Monaco Prompt pack stores prompt fragments; WebuiMonacoPromptTemplate stitches them together. You hand it the file metadata lists from MultiText and JsonFilter, and it recursively expands two template tags inside those files - <include:...> for "paste this file's contents here" and <random:...> for "paste one random line from this file" - into a final prompt string. If you've used Dynamic Prompts or a wildcards folder, this is the same idea made ComfyUI-native, with no extra files sitting on disk.

    The setup is a source_templates port and an entry_points port, both STRING forceInput lists coming from json outputs upstream. Think of it as: source_templates is the card catalog of every fragment the node is allowed to reference, and entry_points is the list of files whose tags actually get expanded - usually the output of JsonFilter, so you can pick which scenes get expanded per run. A third input, seed (INT, 0 to a very big number, default 0), drives the random choices, so the same seed always reproduces the same pick.

    The tag syntax lives right inside the fragment text:

    A photo of <include:character/master.txt>, <include:bg/fantasy.txt>
    Wearing <random:clothing/costumes.txt> standard outfit
    

    <include:...> pulls a referenced file in and then expands any tags inside that file too - that's the recursion, and it's what lets you build prompt parts out of other prompt parts. <random:...> picks a single non-empty line from the referenced file, chosen deterministically from the seed. References are forgiving: you can use a full path, the path minus extension, or just the basename, with or without .txt. A missing target raises a clear "target not found" error rather than silently producing nothing.

    Two safety rails are built in and worth knowing about: circular references (file A includes file B which includes A) are detected and raised, and expansion is capped at ten levels deep so a runaway chain can't stack-overflow the process. Good engineering for a node whose whole job is recursion. Outputs are contents - the expanded prompt strings - and json - the same files with their expanded content written back. contents is what you wire into the text of a CLIPTextEncode node (or a string-concat if you're building a composite prompt).

    Why this is worth it. Prompt structure genuinely matters - the KB's own prompt-engineering notes that the best 2026 results treat a prompt as blocks (tags block, scene block, style block) rather than one run-on line. Template is the tool that makes block-structured prompting painless and reproducible: keep the building blocks in MultiText, pick them with JsonFilter, assemble them here, and the seed port means your random picks are stable across runs instead of rolling fresh every time.

    Gotchas. This node does nothing useful on its own - both forceInput ports need real connections from the pack's other nodes, though the code falls back gracefully to empty output if you leave them unwired. And as with the whole pack, the ComfyUI side is marked experimental by the author. Install is the shared pack install: clone https://github.com/Taremin/webui-monaco-prompt into custom_nodes (or Manager → Install via Git URL), restart, hard-reload the page. No pip deps, no models. The bundled multitext_filter_demo.json workflow demonstrates the full chain end to end - worth dragging onto the canvas before you build your own.

    CategoryWebuiMonacoPrompt

    Inputs (3)

    NameTypeDefaultDescription
    source_templatesSTRING
    entry_pointsSTRING
    seedINT00–18446744073709550000

    Outputs (2)

    NameTypeDescription
    contentsSTRING
    jsonSTRING