ComfyUI Node Runs on cloud

Prompt Parse

Expand wildcards, groups and variables before the prompt hits the encoder

By WASasquatch·Created 4 years ago·Updated about 9 hours ago· 1,884
Prompt Parse
    • text
    • raw_text
    ◄text—►
    ◄mode▾►
    ◄noodle_key__►
    ◄seed0►
    ◄dynamic_promptstrue►
    ◄prompt_variablestrue►

    Prompt Parse is the node that actually does the text-expansion work behind ComfyUI's fancier prompting. Feed it a prompt containing __terms__, <a|b|c> groups or $|phrase|$ variables, and it returns the finished text - the exact markup CLIPTextEncode (NSP) understands, but stopped before the encoder so you can save the result, split it, or encode it elsewhere. If you've been pasting __animals__ into prompts and only half-understanding why the phrase changes each run, this is the node that makes it visible.

    It sits one step back from the encoder deliberately. Rather than hiding the expansion inside a text encoder node, Prompt Parse hands you the resolved string on a socket. That one choice makes the whole thing debuggable: you can see exactly what a given seed drew, and you can wire the finished prompt into a save node so every render keeps a record of the actual text that made it - worth doing, because a resolved prompt is otherwise gone the moment the graph moves on.

    The three markups it resolves

    • __term__ - draws a phrase from the Noodle Soup Prompts terminology pantry, or a line from a wildcard file. mode chooses the source (Noodle Soup Prompts uses the shared pantry, stored in was_state.db), and noodle_key sets the markers on either side - the default __ turns __animals__ into a draw.
    • <a|b|c> groups - dynamic prompt alternation. dynamic_prompts resolves them to one option; turn it off to keep the brackets in the text.
    • $|phrase|$ variables - captures numbered in the order they appear and replaced by $1, $2 and so on. Gated by prompt_variables.

    seed makes the whole parse repeatable: any value other than 0 means the same seed and same input produce the same words every run, which is how you keep a "random" prompt stable while you hunt for the good one.

    Outputs

    text is the finished prompt with every enabled markup expanded. raw_text is the prompt exactly as it arrived, markup and all - handy for a side-by-side save. Both are plain STRING, so they'll feed any text encoder, a Text Concatenate, or Text Save for the archive.

    Where it fits, and the honest caveats

    The pragmatic pattern is Prompt Parse → CLIP Text Encode, with the resolved text also split off to a save node. It plays well with Prompt Tag Cleanup downstream if the pantry draws multi-tag lines you want tidied, and with Noodle Soup Term Edit upstream if you want the pantry to hold your own vocabulary.

    The caveat is the same one that applies to any wildcard setup: expansion is per-run and seed-dependent, so two runs with the same prompt string can produce different actual text unless you pin the seed. That's a feature when you want variation and a trap when you're debugging a specific bad image - which is exactly why the seed input and the text output (save it!) exist.

    Installing

    Prompt Parse is part of WAS Node Suite v3. ComfyUI Manager → search WAS Node Suite v3, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/WASasquatch/was-node-suite-comfyui
    

    Restart after. Needs ComfyUI 0.14.0+ and Python 3.10+. No packages install - v3 runs on what ComfyUI already has. Pulling a real random word from the terminology pantry is local and instant, unlike the old v2 pack's behavior of requiring a pile of extra dependencies just to boot.

    CategoryWAS Suite/Text/Parse

    Inputs (6)

    NameTypeDefaultDescription
    textSTRINGThe prompt, in any of three markups: __term__ = a phrase from the terminology pantry or a line from a wildcard file; <a|b|c> = one of the alternatives; $|a stormy sky|$ = a phrase captured as $1 to repeat later.
    modeCOMBOWhat __terms__ are replaced with. `none` = left alone; `Wildcards` = a random line from the matching file in the wildcards directory, so __animals/birds__ reads animals/birds.txt; `Noodle Soup Prompts` = a phrase from the shared terminology pantry, downloaded once.
    noodle_keySTRING__The marker put either side of a term to flag it for replacement. With the default '__', __animals__ is replaced and plain animals is not.
    seedINT00–18446744073709550000Which words get drawn. 0 = __terms__ differ every run while <a|b|c> groups stay fixed; any other value = the same seed and prompt always give the same text.
    dynamic_promptsBOOLEANtrueWhether <a|b|c> groups are resolved to one of their options. Turn it off to keep the brackets in the text, which is what a prompt being passed on to another parser needs.
    prompt_variablesBOOLEANtrueWhether $|phrase|$ captures are expanded. Each capture is numbered $1, $2 and so on in order, and every reference to that number becomes the phrase, so one long description is written once and repeated.

    Outputs (2)

    NameTypeDescription
    textSTRINGThe finished prompt, with every enabled markup expanded. Worth saving beside the image with Text Save, since a new seed produces different words.
    raw_textSTRINGThe prompt exactly as it arrived, markup and all.