ComfyUI Node

Prompt Key Filter

Stop your JSON prompt from printing itself into the image

By fblissjr·Created 12 months ago·Updated 4 months ago· 188
Prompt Key Filter
    • text
    text
    strip_key_quotestrue
    text_input

    If you've ever handed a JSON-shaped prompt to a Qwen or Z-Image encoder and found the word subject or a stray quote mark literally rendered into the picture, this is the node that cleans that up. That's the whole job. It's small, it's boring, and on the day it saves you it's the best node in the pack.

    Here's why the problem exists. The modern crop of image models - Z-Image, Qwen-Image, Flux 2 - dropped CLIP and encode your prompt with a general-purpose LLM instead. As one teardown in the community put it, the model "is not reading your prompt like CLIP tags, it is reading it like an instruction/message." So when you feed it a structured prompt that the pack's own json_structured template produces - something like {"subject": "a red fox", "style": "oil painting"} - the encoder happily treats the quotes and the key names as part of the message. The DiT then does its best to depict them, and you get quotation marks and the word "subject" smeared across the canvas as if you'd asked for a typography poster.

    How it works

    PromptKeyFilter runs a text cleanup pass before the string ever hits the encoder. It strips the quotes off values ("a red fox" becomes a red fox) and, when you leave strip_key_quotes on, it also de-quotes the keys ("subject": becomes subject:). What's left reads more like a plain description than a data structure, so the model stops trying to draw the scaffolding and just draws the content.

    The inputs and outputs that matter

    • text - the JSON-ish prompt you want cleaned. Type it here, or ignore it and pipe a string in via text_input instead (handy when an LLM node upstream is generating the JSON for you).
    • strip_key_quotes (default on) - the one real knob. On, it removes quotes from keys too; off, it only touches values. Leave it on unless you specifically want the key names preserved for some downstream parser.

    Output is a single text string. Wire it straight into your encoder's prompt input, in place of the raw JSON.

    How to install it

    Through ComfyUI Manager: search ComfyUI-QwenImageWanBridge, install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fblissjr/ComfyUI-QwenImageWanBridge
    

    then restart ComfyUI. The pack itself is lightweight - this particular node is pure string handling and pulls in nothing heavy. The models it feeds (Z-Image at ~6B, or the 20B Qwen-Image family) are the part that costs you VRAM, not this.

    Common issues & troubleshooting

    It didn't fix the text-in-image problem. Make sure PromptKeyFilter actually sits between your prompt source and the encoder - if the raw JSON is still wired directly into the encoder, the filter never runs. It cleans the string that flows through it, nothing else.

    You still see leaked words. Quotes and keys are only one way structure leaks. If your JSON values themselves contain instruction-y phrasing the model wants to render, that's a prompt problem, not a filter problem. Also remember these LLM encoders drift past roughly 75-100 effective tokens, so a giant nested JSON blob hurts adherence regardless of quoting.

    This is a sandbox node. The pack is fblissjr's research repo and openly warns of breaking changes, so treat the exact behavior as subject to drift between updates. For a utility this simple that rarely bites, but it's worth knowing the pack's posture before you build something load-bearing on top of it.

    CategoryQwenImage/Utilities

    Inputs (3)

    NameTypeDefaultDescription
    textSTRINGPaste or type text here. If text_input is connected, this is ignored.
    strip_key_quotesBOOLEANtrueRemove all double quotes from JSON-style prompts. Keys and values both get quotes stripped.
    text_inputoptSTRINGConnect text from another node. Takes priority over the text field.

    Outputs (1)

    NameTypeDescription
    textSTRING