Nodes/ZMG PLUGIN/Multiline Prompt 📝
ComfyUI Node

Multiline Prompt 📝

A prompt text formatter that also counts, numbers, and indexes your lines

By fq393·Created 2 years ago·Updated 7 months ago· 8
Multiline Prompt 📝
    • formatted_prompt
    • total_lines
    • line_count_info
    • original_prompt
    • indexed_line
    • index_info
    • lines_combo
    prompt_text
    line_separator换行符
    custom_separator,
    remove_empty_linestrue
    trim_linestrue
    add_line_numbersfalse
    line_number_format1.
    enable_indexfalse
    line_index0

    Despite the "Prompt" in the name, this node doesn't encode anything and doesn't touch a model. It's a text formatter with a prompt-shaped purpose: you paste a multi-line prompt, and it cleans it up, re-joins the lines however you like, counts them, and can even pull out a single line by index. The output is plain text - you still wire it into a CLIP Text Encode yourself. Think of it as the polite middleman between "how you want to type a prompt" and "what the text encoder wants to receive."

    What it does

    Feed it multi-line text and it processes line by line: strips whitespace (optional), drops empty lines (on by default), and reconnects everything with a separator you choose - newline, comma, semicolon, space, or a custom one. That's the core trick: you can author a prompt as tidy bullet points and ship it to the encoder as a single comma-joined string, which is how most workflows actually want it.

    Inputs that matter

    • prompt_text - your multiline input. The one thing you'll always set.
    • line_separator - 换行符 (newline, keeps lines separate), 逗号 (comma), 分号 (semicolon), 空格 (space), or 自定义 (custom, where custom_separator takes over; default , ).
    • remove_empty_lines / trim_lines - both on by default; turn off if you're preserving structure like paragraph breaks.
    • add_line_numbers + line_number_format - prefixes each line with 1. , (1) , [1] , 1: , or 1 - . Mostly a debugging aid, honestly.
    • enable_index + line_index - grab one specific line (0-based) out of the batch. Useful when each line is a separate candidate prompt and you want to select by number.

    Outputs

    Seven of them, but you'll mostly touch three: formatted_prompt (the processed string - this is what you feed the text encoder), total_lines (an INT, handy for batch math), and original_prompt (the untouched input, for passing through). There's also line_count_info (a human-readable summary), indexed_line and index_info (the picked line and status when indexing is on), and lines_combo - a list output that some downstream nodes can turn into a dropdown selector, which is a nice touch for A/B testing lines.

    Honest verdict

    For pure line-cleaning and joining, plenty of nodes do this (even ComfyUI's core Text Multiline output behaves this way). The indexing and combo outputs are the differentiators, and they're genuinely handy if you're batch-selecting from a list of candidate prompts. If you just want to type a comma-joined prompt once and be done, you don't need it. If you're managing many short prompts, it earns its place.

    Installing

    Part of the ZMG pack. ComfyUI Manager → search "ZMG" / "ComfyUI-ZMG-Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vanche1212/ComfyUI-ZMG-Nodes
    cd ComfyUI-ZMG-Nodes
    pip install -r requirements.txt
    

    Restart, find it under ZMGNodes/text. No dependencies beyond the pack's base set - it's pure string processing.

    CategoryZMGNodes/text

    Inputs (9)

    NameTypeDefaultDescription
    prompt_textSTRING
    line_separatorCOMBO换行符选择输出时的行分隔符
    custom_separatorSTRING, 当选择'自定义'分隔符时使用
    remove_empty_linesBOOLEANtrue是否移除空行
    trim_linesBOOLEANtrue是否去除每行的首尾空白字符
    add_line_numbersBOOLEANfalse是否在每行前添加行号
    line_number_formatCOMBO1. 行号格式
    enable_indexBOOLEANfalse是否启用索引功能,获取指定行的数据
    line_indexINT00–9999要获取的行索引(从0开始)

    Outputs (7)

    NameTypeDescription
    formatted_promptSTRING
    total_linesINT
    line_count_infoSTRING
    original_promptSTRING
    indexed_lineSTRING
    index_infoSTRING
    lines_combo*