Nodes/WebUI Monaco Prompt/WebuiMonacoPromptJsonFilter
ComfyUI Node

WebuiMonacoPromptJsonFilter

The node that picks which prompt parts actually get used

By Taremin·Created 4 years ago·Updated about a month ago· 29
WebuiMonacoPromptJsonFilter
    • contents
    • json
    json_list
    rules[]

    If WebuiMonacoPromptMultiText is the library where your prompt parts live, this node is the librarian. It takes the json output of MultiText - that list of file metadata - and filters it down to the files you actually want, by matching rules against each file's name, path, or contents. Feed it a tree with scenes/ full of fantasy and sci-fi scene files, and it hands back only the ones tagged "fantasy". Whatever survives is what your final prompt gets built from.

    The mechanism is unglamorous and reliable. json_list (a STRING forceInput port, so it only accepts a wired connection from MultiText's json output) arrives as one JSON metadata string per file. Each rule in the rules array is a small JSON object, and the node checks every item against it:

    [
      {"target": "path", "mode": "include", "not": false, "value": "scenes/"},
      {"operator": "AND", "target": "content", "mode": "include", "not": false, "value": "fantasy"}
    ]
    

    Here target is name, path, or content; mode is include (substring match) or regex (full regex via re.search); not flips the result; and every rule after the first takes an operator of AND or OR that says how it combines with what came before. A disabled: true rule is silently skipped. Empty rules, or a rules left at its default [], pass everything through unchanged - which is a handy way to see the whole tree before you start trimming.

    Two inputs, two outputs, and that's the whole node: json_list and rules in, contents and json out. Both outputs are STRING lists holding the same subset - contents is the file bodies for prompt assembly, json is the metadata to hand down the line. The output json plugs straight into WebuiMonacoPromptTemplate's entry_points, which is the actual purpose of this node: it's a routing switch, not a terminal.

    Where people get burned: hand-writing the rules JSON. Get the syntax wrong and the node throws a JSONDecodeError that shows up in the console, not in a friendly widget popup. The good news is the pack ships a filter widget UI in the ComfyUI front end, so you can build rules by filling in dropdowns instead of typing brackets - use it. Also note that only files of type file are ever in the list to begin with; folders were already stripped out by MultiText. And if you connect nothing to json_list, the node won't run - that port is forceInput, which means "this input must be wired", on purpose.

    Install is shared with the whole pack: clone into custom_nodes or use Manager's "Install via Git URL" (https://github.com/Taremin/webui-monaco-prompt), then restart ComfyUI. No pip dependencies, no model files, no API keys - this is pure local UI logic. Just remember the ComfyUI side is officially experimental, and give the page a hard reload after install. The pack's bundled demo (multitext_filter_demo.json) is the fastest way to see this node doing its job: MultiText → JsonFilter → Template → Preview, with the filter selecting a scenes/ path that also contains fantasy.

    CategoryWebuiMonacoPrompt

    Inputs (2)

    NameTypeDefaultDescription
    json_listSTRING
    rulesSTRING[]

    Outputs (2)

    NameTypeDescription
    contentsSTRING
    jsonSTRING