Nodes/ComfyLab Pack/Format: Multiline (lab)
ComfyUI Node

Format: Multiline (lab)

String, for prompts that span lines

By bugltd·Created 2 years ago·Updated about a year ago· 11
Format: Multiline (lab)
    • formatted
    formatfirst arg by name: {arg0} second by index: {1}

    Format: Multiline (lab) is Format: String (lab) with a bigger text box. Same engine - Python str.format(), unlimited typed inputs, {arg0} or {0} placeholders - but the template is a multiline field, so you can lay out a prompt or a block of text across several lines and have the formatting apply across all of them at once.

    The single-line version handles "build me a string." The multiline version handles "build me a prompt." ComfyUI prompts are usually pasted as multi-line text - structure, line breaks, weight notation spread across lines - and when you want to inject varying values into that structure, trying to do it on one line is miserable. This node lets you keep the multi-line layout human-readable and only swap the parts that change.

    How it works

    Identical mechanics to Format: String: the template holds placeholders, inputs connect dynamically (STRING, INT, FLOAT, BOOLEAN), and references work by name ({arg0}) or index ({1}). Because it's real format(), all the specifiers carry over - padding, truncation, number formatting - which is more useful here than it sounds: keep one line as {cfg:.1f} and the number renders cleanly mid-prompt.

    Input: format (the multiline template). Output: formatted (the completed multiline string).

    Where it earns its keep

    • A prompt with a slot - best quality, {subject}\ncinematic lighting, (golden hour:1.2)\n{extra} with subject and extra wired from elsewhere (or a queue).
    • Batch prompt variation - the varying part comes from a queue node, the fixed multi-line structure stays in the template. This is the "keep the structure, vary the subject" pattern from the KB's prompt-engineering material, made explicit.
    • Anything you'd write in a Notes node that needs values dropped in at build time.

    If you're building prompts with only one or two dynamic values, this node's template is effectively your prompt editor with inputs stitched in - a genuinely nicer way to work than concatenating three nodes.

    Install

    ComfyLab Pack installs as one package (nodes display with "(lab)" suffixes). ComfyUI Manager: search ComfyLab Pack, install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bugltd/ComfyLab-Pack.git
    cd ComfyLab-Pack
    pip install -r requirements.txt
    

    Restart after. No model files; light requirements.

    Gotchas

    • Same brace rules as the single-line version - unmatched { errors at run time, literal braces are {{.
    • Line breaks are part of the output. The template's newlines are preserved, which is almost always what you want for prompts, but it means the output string contains \n - if you pipe it somewhere that expects a single line, strip them first.
    • Pick one reference style per template - mixing {arg0} and {0} is asking for confusion.
    • It does not split into a list. Formatting a multiline string is not the same as List: from Multiline; different tools for different jobs. Need one value per line as a list? That's the list node. Need one assembled string? This one.

    For prompt work, the multiline box is the whole difference. You keep reading your own template a week later, which is more than most prompt-engineering hacks can say.

    CategoryComfyLab/utils

    Inputs (1)

    NameTypeDefaultDescription
    formatSTRINGfirst arg by name: {arg0} second by index: {1}placeholders can be either '{arg0}', '{arg1}, ... or '{0}', '{1}', ...

    Outputs (1)

    NameTypeDescription
    formattedSTRING