Nodes/Mikey Nodes/Remove Text Between (Mikey)
ComfyUI Node

Remove Text Between (Mikey)

Remove Text Between (Mikey Nodes) — strip out a reasoning model's <think> block

By bash-j·Created 3 years ago·Updated 10 months ago· 188
Remove Text Between (Mikey)
    • text
    • removed_text
    textInput Text Here
    start<think>
    end</think>

    The default values on this node's inputs tell you exactly what it's for before you even read a description: start defaults to <think> and end defaults to </think>. If you've run a reasoning model like DeepSeek-R1 or QwQ locally, you already know what that means - those models emit a whole block of internal reasoning wrapped in think-tags before they get to the actual answer, and if you're piping that raw output into a CLIP Text Encode node, all that reasoning text ends up in your prompt.

    The mechanism

    It's a plain substring extractor, and it's generic despite the think-tag defaults - start and end are just optional text inputs you can override to strip any delimited chunk out of a block of text, not only think-tags. Feed it a text block, tell it what marks the start and end of the section you don't want, and it returns two things: the cleaned text with that section removed, and the removed section on its own, in case you actually want to inspect or log it separately rather than throw it away.

    Inputs and outputs

    One required input: text, a multiline string - this is whatever block of text you want cleaned up. Two optional inputs, start and end, defaulting to the <think> / </think> pair but freely overridable to any pair of markers you need. Two outputs: text (the cleaned version, with everything between start and end removed) and removed_text (just the part that got cut).

    The obvious place this slots in: right after Mikey Nodes' own LM Studio Prompt or OobaPrompt nodes, if the local LLM you're running through them happens to be a reasoning model. Chain Remove Text Between in between the LLM node and your CLIP Text Encode, set start/end to whatever tag format your specific model uses (most reasoning models standardized on <think>/</think>, but check your model card if it uses something else), and you get a clean prompt string with the model's internal monologue routed to removed_text instead of bleeding into your generation.

    Installing

    Part of the full pack - ComfyUI Manager, search "Mikey Nodes," install, restart, or clone it manually with git clone https://github.com/bash-j/mikey_nodes into ComfyUI/custom_nodes and restart. Nothing extra to set up for this specific node; it's pure string processing with no model or external service dependency of its own.

    Where it can trip you up

    • Wrong tag format for your model. Not every reasoning model uses <think>/</think> - some use different delimiters entirely. If the output still has reasoning text in it after running through this node, the first thing to check is whether your model's actual tag format matches what you set start/end to.
    • Nested or repeated tags. If a model's output contains the start/end markers more than once, or nests them, a simple substring extractor can behave unpredictably (typically it'll only handle the first pair, or grab from the first start to the last end rather than each pair independently). If your model does this, you may need to chain the node twice or clean the text another way.
    • Using it on text that was never wrapped in tags to begin with. If start never appears in the input, text passes through unchanged and removed_text comes back empty - which is correct behavior, not a bug, but worth knowing so you don't go looking for a problem that isn't there.
    CategoryMikey/Text

    Inputs (3)

    NameTypeDefaultDescription
    textSTRINGInput Text Here
    startoptSTRING<think>
    endoptSTRING</think>

    Outputs (2)

    NameTypeDescription
    textSTRING
    removed_textSTRING