ComfyUI Node

Prompt Replace Parser

Chinese prompt surgery with zero dependencies

By cction·Created 3 months ago·Updated 3 months ago· 1
Prompt Replace Parser
    • prompt_list
    • prompt_text
    • style_text
    source_text
    override_text

    The name is a lie, and that's the good news

    "Vivid Prompt Analysis" sounds like it should call some AI API and write your prompt for you. It doesn't. This one node from the cction/ComfyUI-Vivid-Prompt-Analysis-Replacement pack is pure string surgery - it takes a structured Chinese prompt, lets you override a couple of fields, and hands you a clean merged version. No models, no API keys, no torch. Just Python's standard library: json, ast, and re. The requirements.txt literally reads "Runtime dependencies: none."

    The "Replacement" in the pack name is doing real work: this is a re-hosted copy of a node that originally shipped somewhere else (the README calls it "the original implementation"), repackaged so it installs cleanly on its own. Author is "Vivid," the whole thing is one file, MIT licensed, and there's a small pytest suite if you want to verify it before trusting it.

    Why you'd reach for it

    If you've never seen this format, walk away - it's a niche tool for a specific Chinese-language workflow. The fields it knows are 目标/保留/迁移/环境/光影/细节/输出 (goal, keep, migrate, environment, lighting, details, output), plus 类型选择 (type selection). That's the shape of an architecture-rendering prompt: "构建现代建筑方案" (build a modern building scheme), with 类型选择 values like 精细模型 (detailed model) or 体块模型 (massing model). Somewhere upstream - an LLM, a captioning step, another app - produces a structured description in this exact format, and you want to hand-edit one or two fields in ComfyUI without retyping the whole thing. That's the entire job, and it does it in a few milliseconds.

    It also slots into the "structure your prompt in blocks" habit that actually survived the move to LLM-based text encoders. Your prompt is an instruction, not a token bag, so keeping sections tidy and consistent matters more than it used to.

    How it works

    source_text is parsed three ways, in order: json.loads, then ast.literal_eval (so Python dict literals work), then a labeled-text fallback that scans for 字段:内容 lines. The expected shape is {"转换描述": {"目标": "...", ...}, "类型选择": "..."}.

    override_text is simpler - a dict or the same labeled format. Then comes the merge: for each of the seven fields, the override wins only if it has real content and contains Chinese characters. Otherwise the source value survives. Whatever survives gets a appended if it's missing sentence-ending punctuation, every output line has all whitespace stripped, and the field is dropped entirely if neither source nor override had anything meaningful.

    Three outputs, two of which matter:

    • prompt_list - the merged lines as a Python list (目标:构建现代建筑。, 环境:滨水平台。, …), for nodes that want a sequence
    • prompt_text - the same lines joined with newlines; this is the one you feed into a CLIP text encode or your model's text encoder
    • style_text - the 类型选择 value (override preferred, source as fallback), handy if you want to branch the style tag off on its own

    Where people get burned

    This is a small node, but the traps are real:

    • Overrides must contain Chinese. Write 环境: plaza as your override and it's silently ignored - the base value wins. The validity check requires meaningful content and Chinese characters, and there's a test locked onto exactly this behavior.
    • Labels are a fixed list. Only the seven fields plus 类型选择 are recognized. 主题: or 风格: get parsed and never merged into output. English labels are gone entirely.
    • Whitespace is destroyed. Every output line is stripped of all whitespace, so don't plan on pretty formatting, and don't be alarmed when your aligned text collapses.

    Installing

    ComfyUI Manager, search "Vivid Prompt Analysis" (or the pack title comfyui-vivid-prompt-analysis-replacement) and install. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cction/ComfyUI-Vivid-Prompt-Analysis-Replacement
    

    Then restart ComfyUI. No model downloads, no pip installs - it shows up as Prompt Replace Parser under the PromptTools category immediately. That's the whole install story, which for a "replacement" pack is the point.

    Honest verdict: if you're running a Chinese structured-prompt (likely architecture/AIGC) workflow, this is dependable glue with zero install footguns. If you're not, there's nothing here for you - and that's fine, it isn't trying to be anything else.

    CategoryPromptTools

    Inputs (2)

    NameTypeDefaultDescription
    source_textSTRING
    override_textSTRING

    Outputs (3)

    NameTypeDescription
    prompt_list*
    prompt_textSTRING
    style_textSTRING