Nodes/ComfyUI Prompt Template/MIM Prompt Template Constructor
ComfyUI Node

MIM Prompt Template Constructor

MIM Prompt Template Constructor

By DaniilVdovin·Created 11 months ago·Updated 11 months ago· 1
MIM Prompt Template Constructor
  • clip
  • positive
  • negative
  • positive
  • negative
  • json
template_positiveA *obj on a *place
template_negative
variables_json{"obj": "cat", "place": "table"}

If the plain Json node from this pack is "the one with the JSON textarea you have to type into", the Constructor is the one where you never see the JSON at all. Under the hood it's the exact same class - check the pack source and PromptTemplateJsonConstructor maps to the same PromptTemplateJson implementation, inputs and outputs and all. What's different is the front end: a custom JavaScript UI that swaps the raw JSON box for a proper key/value editor with rows you can add and remove.

The feature that makes it worth using over the plain version is the Load from Prompt button. Write a template like A *character in *outfit on *background, click it, and the node scans your positive and negative templates, pulls out every *variable, and pre-creates an empty field for each. Type the values in, done. No JSON syntax, no trailing-brace panic. For a beginner this is the friendliest on-ramp into the pack's *var workflow.

How it works

The Python side is identical to Prompt Template Json: it reads the variables_json widget, substitutes every *key into the templates, and - when a clip is connected - encodes the results straight to conditioning. The magic lives in the web extension (web/js/extension.js), which hides the JSON textarea, renders the key/value rows, and writes your edits back into the widget as properly formatted JSON so the graph saves and loads normally. It's a thin, well-contained UI wrapper, and it's why the two node classes behave identically once the graph actually runs.

Inputs and outputs

Identical to the Json node: template_positive, template_negative, variables_json (now populated by the UI instead of your typing), and an optional clip. Outputs are positive/negative CONDITIONING for the KSampler, positive/negative STRING for the resolved text, and a json STRING echo.

One constraint that comes from the UI's regex: variable names must look like identifiers - start with a letter or underscore, then letters, digits, or underscores. *outfit_2 is fine; *out-fit or *2nd style won't be picked up by the button.

Installing

Same as the rest of the pack - no dependencies, no model downloads, pure stdlib. Via Manager, search "ComfyUI Prompt Template"; or:

cd ComfyUI/custom_nodes
git clone https://github.com/DaniilVdovin/ComfyUI-prompt-templating.git

Restart ComfyUI and it appears in the MIM_Prompts category.

Known quirks

The author is upfront about the one real blemish: the custom UI is built for a big node. Shrink the node too far and the rows and buttons get cramped and hard to read - the README literally says it "only looks good in a larger view." So when you drop this in, give it room; it's a UI habit, not a correctness problem. Otherwise expect the same behaviors as the Json node: malformed JSON fails silently (leaving *var literal), and variable names shouldn't be prefixes of each other, or the naive replace will mangle them. The Constructor just makes the JSON part so easy you'll rarely hit that failure yourself.

CategoryMIM_Prompts

Inputs (4)

NameTypeDefaultDescription
clipoptCLIP
template_positiveoptSTRINGA *obj on a *place
template_negativeoptSTRING
variables_jsonoptSTRING{"obj": "cat", "place": "table"}

Outputs (5)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING
positiveSTRING
negativeSTRING
jsonSTRING