Nodes/ComfyUI-CSV-prompt-builder/Build Prompt From CSV
ComfyUI Node

Build Prompt From CSV

Turn a Spreadsheet Into a Prompt Generator (No Wildcards Required)

By jroc22·Created 2 years ago·Updated 2 years ago· 16
Build Prompt From CSV
    • STRING
    csv_filecat_hat.csv
    seed42
    CAT_modeCycle
    CAT_val
    CAT_weight1.00
    CAT_to_HAT,
    HAT_modeRandomize
    HAT_val
    HAT_weight1.00

    Want 100 different prompts without writing 100 prompts? That's the whole point of BuildPromptFromCSV. You stick your prompt ingredients in a CSV, the node turns each column into a dropdown on the node, and every time you run the workflow it assembles a fresh combination. It's the old A1111 wildcard trick ({a cat|a dog|a horse}) made visual and spreadsheet-driven - which, honestly, is a nicer way to keep track of a large prompt library than a wall of curly braces.

    The author is upfront that this is their first node and their first coding project, and it shows in places: switching CSV files requires a ComfyUI restart, and there's no way to have two instances pointed at different files. But for the core job - batch-generating variety without hand-typing every prompt - it's dead simple and it works. The person who recommended it in the wild pitched it exactly the way you'd want: queue up a few hundred runs, let Cycle walk through the combinations, come back to a folder full of variations.

    How it works

    The node reads whichever CSV is selected, and the column headers become the node's inputs. A file with SUBJECT,CLOTHING,BACKGROUND gives you SUBJECT_mode, SUBJECT_val, SUBJECT_weight, and so on for each column, plus separator fields between them. Drop a CSV in, and the node rebuilds its inputs around whatever headers you used.

    Each column gets three controls that matter:

    • {column}_mode - Fixed (use the value you pick), Randomize (grab a random one, seeded by the node's seed input), or Cycle (walk down the column in order, wrapping around to the top). Cycle is the one you want for batch runs.
    • {column}_val - the value to use in Fixed mode. Pick None and that column gets skipped entirely, which is handy for leaving a slot empty on purpose.
    • {column}_weight - if you set it to anything other than 1.0, the node wraps the value in A1111-style attention syntax: (a cute cat:1.25). That's the same (keyword:1.3) weighting from the classic SD 1.5/SDXL era - just remember it does nothing on LLM-encoded models like Flux or Anima, where it becomes literal punctuation in the prompt.

    Between columns, the {column}_to_{next} fields are the separators, default ", ". The README's trick: make one an input and wire in a multi-line string node to inject whole chunks of text between columns, as long as you keep your separators on both ends.

    The output is a single STRING with everything joined together. Wire it into a CLIP Text Encode for SD 1.5/SDXL/Illustrious-style models, or whatever encoder your checkpoint wants.

    Installing it

    No dependencies, no model downloads - the whole thing is pure Python stdlib. Install it like any node:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jroc22/ComfyUI-CSV-prompt-builder.git
    

    Restart ComfyUI, and you'll find Build Prompt From CSV under the Prompt Nodes category. Or search "ComfyUI-CSV-prompt-builder" in ComfyUI Manager and let it handle the clone. Your CSVs live in the prompt_sets/ folder inside the node's directory - headers in the first row, at least one value under each header, and keep headers short because they literally become input names.

    Where people get burned

    This is a restart-heavy node, and it'll bite you if you don't expect it:

    • Changing the CSV file is a three-step ritual: pick the new file in the dropdown, run the node once (it'll raise an error telling you to restart), then restart ComfyUI. It can't hot-swap, full stop.
    • Editing a CSV you're already using - even just adding a row - won't show up until restart, because columns are cached when the node loads.
    • Deleting the loaded CSV makes the node silently fall back to the first CSV (alphabetically) in prompt_sets/, and the dropdown may still show the old name. There's a _csv_config.json in prompt_sets/ that tracks the current file; if the node won't initialize, that config is the first thing to check.
    • Multiple instances can't use different CSV sources. Workaround the author suggests: convert csv_file to an input and connect a shared Combo node to every instance.

    None of that is a reason to avoid it - restarting is a two-second annoyance - but go in knowing the drill. If you just want a quick way to make a batch of varied prompts from a list you already keep in a spreadsheet, this is one of the simplest tools for it.

    CategoryPrompt Nodes

    Inputs (9)

    NameTypeDefaultDescription
    csv_fileCOMBOcat_hat.csv2 options: example.csv, cat_hat.csv
    seedINT420–4294967295
    CAT_modeCOMBOCycle3 options: Fixed, Randomize, Cycle
    CAT_valCOMBO7 options: None, a cat, a kitty cat, a small cat, a big cat, a cute cat, +1
    CAT_weightFLOAT1.000–5
    CAT_to_HATSTRING,
    HAT_modeCOMBORandomize3 options: Fixed, Randomize, Cycle
    HAT_valCOMBO12 options: None, in a hat, in a big hat, in a small hat, in a medium hat, in a tall hat, +6
    HAT_weightFLOAT1.000–5

    Outputs (1)

    NameTypeDescription
    STRINGSTRING