Nodes/ComfyUI-Flux2Klein-Enhancer/FLUX.2 Klein Sectioned Encoder
ComfyUI Node

FLUX.2 Klein Sectioned Encoder

Writing prompts in real, addressable sections

By capitan01R·Created 7 months ago·Updated 30 days ago· 551
FLUX.2 Klein Sectioned Encoder
  • clip
  • conditioning
  • front_section
  • mid_section
  • end_section
  • full_prompt
front_text
mid_text
end_text
combined_prompt
separatorcomma
show_previewtrue
debugfalse

Klein reads prompts like an LLM chat message rather than a bag of weighted tags, which is great for natural sentences and useless for the old trick of bumping one word's weight. This node is what makes structured prompting possible instead: split your prompt into FRONT/MID/END sections up front, and the node remembers exactly which tokens belong to which section - so a downstream node can actually weight them independently later.

Why this exists as its own node

You could just write a normal prompt into a plain CLIP Text Encode. The reason to use this instead is entirely about what it records, not what it outputs - the final encoded prompt looks like any other conditioning, but this node also stashes the real, tokenizer-derived ranges for each section in meta["klein_sections"]. That metadata is what lets Detail Controller, wired right after this, scale FRONT/MID/END independently and correctly, instead of guessing at an arbitrary token split.

The README's suggested structure maps sections to job: FRONT for subject and primary action, MID for clothing and scene details, END for lighting and rendering style. That's a convention, not a hard rule - but it's a sensible default if you don't already have your own structure in mind.

The inputs and outputs that matter

  • clip - required, your loaded CLIP/text-encoder connection.
  • front_text / mid_text / end_text (optional, multiline) - write each section separately in its own box.
  • combined_prompt (optional, multiline) - an alternative to the three boxes: write one prompt using [FRONT]/[MID]/[END] markers, and it overrides the separate boxes whenever it's non-empty and actually contains those markers.
  • separator (optional, default comma) - how sections get joined into the final prompt string sent to Klein: comma, period, space, or newline.
  • show_preview (optional, default true) - shows what the assembled prompt actually looks like, useful for sanity-checking the join before you commit to a long render.

This node is one of the few in the pack with multiple outputs: conditioning (wire to your sampler or into Detail Controller), plus front_section, mid_section, end_section, and full_prompt as raw strings - handy for debugging, or for feeding into emphasis_start/emphasis_end token-range lookups on Detail Controller if you need finer control than the section boundaries give you.

Installing it

ComfyUI Manager: search ComfyUI-Flux2Klein-Enhancer, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/capitan01R/ComfyUI-Flux2Klein-Enhancer.git

No extra dependencies.

Where people get burned

This node by itself doesn't do anything Detail Controller-flavored - no weighting happens here. If you build this node and don't chain Detail Controller after it, you've just written a slightly more organized prompt with no functional benefit over a plain CLIP Text Encode. The value is entirely in the pairing.

Leaving a section blank is fine - an empty mid_text just means nothing gets contributed there - but if you're relying on combined_prompt and forget one of the [FRONT]/[MID]/[END] markers, that section silently comes back empty rather than erroring, which can be confusing when Detail Controller later reports weighting a section that has nothing in it. Turn show_preview on while you're setting this up so you can catch a missing marker before it costs you a render.

Categoryconditioning/flux2klein

Inputs (8)

NameTypeDefaultDescription
clipCLIP
front_textoptSTRINGFRONT section text.
mid_textoptSTRINGMID section text.
end_textoptSTRINGEND section text.
combined_promptoptSTRINGOptional. Single prompt with [FRONT]/[MID]/[END] markers — overrides the three text boxes when non-empty and contains markers.
separatoroptCOMBOcommaHow to join sections in the final prompt sent to Klein.
show_previewoptBOOLEANtrue
debugoptBOOLEANfalse

Outputs (5)

NameTypeDescription
conditioningCONDITIONING
front_sectionSTRING
mid_sectionSTRING
end_sectionSTRING
full_promptSTRING