ComfyUI Node

Template Loader

File-based presets with Template Loader

By r3dsd·Created 2 years ago·Updated 2 years ago· 0
Template Loader
    • STRING
    sourcesituation.example
    template

    If you've ever had ten workflow variants that differ only in the prompt text box, you've already invented this node in your head. Template Loader is a three-line idea done properly: it keeps your go-to prompts in plain JSON files and hands them to your graph as dropdowns. Pick a file, pick a key, get a STRING. That's the whole job, and unlike half the custom node ecosystem it doesn't sneak a dozen dependencies in with it.

    It's worth knowing where that string goes. In ComfyUI a prompt is just data - it flows from a text box into a CLIP Text Encode node, becomes conditioning, and feeds the sampler. Whether you're on an SDXL booru-tag model or a 2026 LLM-encoded checkpoint where your prompt gets wrapped in a chat template, the input side is still a plain string. Template Loader doesn't care which you run; it just returns text, so it slots into the same CLIP Text Encode port you already use.

    How it works

    Under the hood it's aggressively simple. The node scans custom_nodes/comfyui-template-loader/template/ for every .json file (including subfolders), reads each as a {"Key": "prompt string"} dictionary, and builds two dropdowns. Pick the source, and a tiny bit of frontend JS calls a local /templates?name= endpoint to repopulate the key list. The output is whatever string that key maps to, verbatim - no escaping, no wildcards, no mangling of your (word:1.2) or booru tags.

    The inputs and output

    Only two inputs exist, and you'll set both from dropdowns:

    • source - the JSON file to read from, named without the .json extension (e.g. situation.example).
    • template - which key inside that file to return (EatingBurger, EatingPizza in the shipped example).

    The single STRING output wires straight into a CLIP Text Encode's text input - positive, or negative if you keep a stock negative preset.

    Setting it up

    ComfyUI Manager covers this one: search for "comfyui-template-loader" and hit install. Or do it by hand:

    cd ComfyUI/custom_nodes && git clone https://github.com/r3dsd/comfyui-template-loader
    

    Then restart ComfyUI. That's genuinely all - there's no requirements.txt, no model downloads, nothing heavy. The whole pack is the node, a server endpoint, and a Python stdlib glob. Given how many nodes arrive dragging conflicting package versions into your environment, a zero-dependency utility is refreshing.

    Your template file goes in the template folder and looks like this:

    {
      "eating_burger": "burger, holding burger, open mouth, smile, solo, happy",
      "eating_pizza": "eating, pizza, pizza box, holding, solo, happy"
    }
    

    Save it as situations.json, restart, and both keys appear in the dropdown.

    Where people get burned

    • Edits need a restart. Loaded files are cached in memory with no invalidation. Change a JSON while ComfyUI is running and the node keeps serving the old prompt until you restart. Annoying, but predictable.
    • The template dropdown is a union of every key across every file, so the list gets long fast - and if two files share a key name you can't tell which file a dropdown entry came from. Keep keys unique.
    • Malformed JSON doesn't crash, it just lies. A broken file makes the dropdown show Load failed [invalid JSON]; a missing one shows Load failed [not found]. Usually means a trailing comma.

    It won't change your life if you retype one prompt a day. But if you batch character presets or style bases, keeping them in editable JSON beats hunting through saved workflows - and you can version the files with everything else you already track.

    CategoryTemplateLoader

    Inputs (2)

    NameTypeDefaultDescription
    sourceCOMBOsituation.example1 options: situation.example
    templateCOMBO2 options: EatingBurger, EatingPizza

    Outputs (1)

    NameTypeDescription
    STRINGSTRING