Nodes/ComfyUI-EZ-AF-Nodes/EZ Extract Prompt
ComfyUI Node

EZ Extract Prompt

Pull just the section you want out of a formatted block

By ez-af·Created 2 years ago·Updated 3 months ago· 28
EZ Extract Prompt
    • STRING
    string
    searchword
    extract_allfalse
    pass_originalfalse

    EZ Extract Prompt is the other half of the EZ-AF CSV story. The loaders give you one big blob of text - a CSV row with every column prefixed by a header, or a prompt file with section markers - and this node slices out the one piece you actually want. You ask for the Prompt section and you get just the prompt, cleanly, ready to feed a text encoder. It's a small node with a specific job, and it does it well enough that it's the difference between "CSV loader is a fun demo" and "CSV loader is my prompt database."

    How it works

    The input format it parses is the loader's own output style, which looks like:

    [Name = knight]:
    full armor, steel plate
    
    [Prompt]:
    knight in armor, dramatic lighting, dark forest
    

    You set searchword to a header name (it matches case-insensitively, and trailing colons are tolerated), and the node starts collecting lines the moment it hits that header, stopping at the first blank line. So searchword = prompt gives you back exactly knight in armor, dramatic lighting, dark forest. The blank line is the terminator - which is why the loaders format blocks the way they do.

    The two booleans cover the edge cases:

    • extract_all - ignores headers entirely and returns the original text with blank lines and header lines stripped out. Use this when you want the whole row's content without any [Header = ...] noise.
    • pass_original - if the searchword isn't found and extraction comes up empty, it passes the original input through instead of returning nothing. Handy for fallback logic: "if there's no negative section, just give me whatever was there."

    What it pairs with

    The README's intended chain is: EZ CSV Loader (or EZ Prompt Loader) → EZ Extract Prompt → CLIP Text Encode. A typical CSV row holds several columns - name, positive, negative, size - and you run one extractor per column you need, each with a different searchword. You can also feed it plain text you've formatted yourself with the same [Header]: convention; nothing about it is tied to the loaders beyond the format.

    Install and gotchas

    It's in the EZ-AF Nodes pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ez-af/ComfyUI-EZ-AF-Nodes.git
    

    restart or use ComfyUI Manager → search ez-af. The main gotcha is the blank-line terminator: if your CSV column value contains blank lines in the middle, the extractor stops at the first one. Keep values single-paragraph and you'll never notice. Also note extraction stops at the first matching header, so duplicate headers in a row only ever return the first block - another reason to keep column headers unique.

    CategoryEZ NODES

    Inputs (4)

    NameTypeDefaultDescription
    stringSTRINGText to be processed.
    searchwordSTRINGHeader name to be searched.
    extract_allBOOLEANfalseIf true, extracts the original text of all headers, removing extra line breaks.
    pass_originalBOOLEANfalseIf true, passes the original input to output when no searchword is found.

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGProcessed text.