Nodes/Folded prompts/FP Text Clean And Splitt
ComfyUI Node

FP Text Clean And Splitt

Comment lines out, AR regions in — FP Text Clean And Splitt does the boring parsing

By akawana·Created 9 months ago·Updated 7 days ago· 6
FP Text Clean And Splitt
    • all_expt_comments
    • all_expt_areas
    • ar_list
    • impact_wildcard
    text
    before_text
    after_text

    Regional prompting in ComfyUI has an ergonomics problem: you end up with one big text block where commented-out lines and <AR1>...</> region tags sit in the same soup, and you have to keep the main prompt clean by hand. FP Text Clean And Splitt (yes, two t's - the name is a typo that made it into production) is the parser that does it for you. Feed it raw text, get back clean main text, five separate region strings, and an Impact Pack wildcard. It's the utility that makes the Folded Prompts editor's tree mode output actually usable, and it works on any text you paste in, not just text from that pack.

    What it actually does

    Pure Python, no AI, no models. The pipeline is easy to follow:

    • //-prefixed lines are treated as comments and stripped. The prefix is read from your ComfyUI settings under keybinding_extra.comment_prefix - whatever you set the pack's line-comment shortcut to (default //), this node honors.
    • <AR1>...</> through <AR5>...</> blocks are detected. The closing tag is </> - that's the whole convention, no need to rename closers.

    You get four outputs, each a different "view" of the same text:

    • all_expt_comments (STRING) - comments removed, AR tags stripped but their content kept, blank lines collapsed, and every tag reformatted to end with a comma. This is your main prompt, ready for CLIP Text Encode.
    • all_expt_areas (STRING) - the same cleaning, but AR blocks are removed entirely, tags and content. For when you want the base prompt with no regions at all.
    • ar_list (LIST) - one entry per region, AR1 through AR5 in order, cleaned and flattened; regions you didn't use come back as None.
    • impact_wildcard (STRING) - the same regions reformatted as an Impact Pack wildcard: a [LAB] line followed by [AR1].../[AR2]... lines, ready to drop into Impact Pack's wildcard node so a workflow can pick regions dynamically. Impact Pack quietly owns most of the ecosystem's wildcard machinery, so this output is the "send it downstream" path.

    Inputs are simple: text (your multiline prompt), plus optional before_text and after_text that get concatenated around it before parsing.

    Install

    Same deal as the rest of the pack - no models, no dependencies beyond the Python stdlib:

    • ComfyUI Manager → Install, search Folded prompts, install, restart.
    • Or manually:
      cd ComfyUI/custom_nodes
      git clone https://github.com/akawana/ComfyUI-Folded-Prompts.git
      then restart.

    Common gotchas

    Commented lines not disappearing? Your comment prefix isn't // - check Settings → Keybinding Extra, since this node reads that exact setting and honors a custom prefix.

    Only AR1AR5 and <ALL> are recognized. There's also an <ALL> tag whose content gets prepended to every region in ar_list - useful as a shared base like 1girl, masterpiece that applies to all regions at once.

    And the None entries in ar_list: don't feed them to a node that chokes on nulls. The Impact Pack wildcard output is the safer route when you want regions consumed downstream. For anyone hand-writing regional prompts, this turns a fiddly regex habit into one node.

    CategoryAK/Folded Prompts

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    before_textoptSTRING
    after_textoptSTRING

    Outputs (4)

    NameTypeDescription
    all_expt_commentsSTRING
    all_expt_areasSTRING
    ar_listLIST
    impact_wildcardSTRING