Files
da2el-ai-D2-nodes-ComfyUI/docs/en/node_text.md
T
da2el-alandClaude Opus 4.8 f70302a9a9 docs: D2_PromptSanitizer remove_extra_comma docs and bump version to 31.2.0
Document the new remove_extra_comma option in 3 languages and bump
the package version (existing-node enhancement, minor bump).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 20:15:39 +09:00

7.0 KiB

English | 日本語 | 繁体中文

Node

🍅 Text Node

D2 Regex Replace

  • Can replace using regular expressions
  • Multiple conditions can be specified
  • Supports reuse of regex match strings (e.g., \1, \2)
  • Target string can be specified by "tag unit" or "whole"

Input

  • text
    • Target string for search
  • mode
    • Tag: Break down text by newlines and "," and replace individually
    • Advanced: Replace text as a whole
  • regex_and_output
    • List of search strings and output strings
    • Write in following format
    • If output string is empty, matched part is deleted
    • No limit on number of entries
Search string 1
--
Output string 1
--
Search string 2
--
Output string 2

Output

  • text
    • Text after replacement

Sample

Sample for removing Pony series quality tags.

Mode: Tag

Input text

score_9, score_8_up, (score_7_up, score_6_up:0.8) , rating_explicit, source_anime, BREAK
1girl, swimsuit

Regex Replace

.*(score_|rating_|source_).*
--
--
BREAK
--

Output text

1girl, swimsuit

D2 Regex Switcher

  • Searches input text with regex and outputs matching text
  • Main purpose is switching quality tags per Checkpoint
  • When matching string is found in input text, outputs target string and match index (starting from 0)
  • Can concatenate strings at front and back

Input

  • text
    • Search target string
  • prefix
    • String to concatenate at front
  • suffix
    • String to concatenate at back
  • regex_and_output
    • List of search strings and output strings
    • Write in following format
  • pre_delim
    • Character inserted between prefix and regex_and_output
    • Comma: , / Line break: newline / None: nothing
  • suf_delim
    • Character inserted between regex_and_output and suffix

Output

  • combined_text
    • String combining prefix + output string + suffix
  • prefix / suffix
    • Input passthrough

D2 Multi Output

  • Node that outputs generic parameters like seed and cfg as lists

Input

  • type
    • FLOAT: Floating point numbers. For CFG etc.
    • INT: Integers. For steps etc.
    • STRING: Strings. For sampler etc.
    • SEED: Can input seed values with random number button
  • Add Random
    • Adds random numbers to input field
    • Only shown when type is SEED

D2 Filename Template / D2 Filename Template2

  • A node for creating string templates by incorporating date and parameters from other nodes
  • D2 Filename Template2 is a version that supports multiple lines
  • It is also possible to retrieve values from arrays, dictionaries, and objects
  • Preset feature for commonly used formats like Stable Diffusion webui A1111-style metadata
    • You can add presets by editing custom_nodes/d2-nodes-comfyui/config/template_config.yaml

Input

  • arg_{number}
    • Import values from other nodes
  • format
    • %date:{yyyy/MM/dd/hh/mm/ss}%
      • yyyy: Year
      • MM: Month
      • dd: Day
      • hh: Hour
      • mm: Minute
      • ss: Second
    • %{node name}.{key}%
      • Retrieves values by specifying node name and item name
      • Example: %Empty Latent Image.width%: Get width from the Empty Latent Image node
    • %node:{id}.{key}%
      • Retrieves values by specifying node ID and item name
      • Example: %node:8.width%: Get width from node ID 8
    • %arg_{number}%
      • Embed input values
    • %arg_{number}:ckpt_name%
      • Embed checkpoint name with .safetensors removed
    • %arg_{number}:preset.{preset_name}%
      • Presets can be added by editing custom_nodes/d2-nodes-comfyui/config/template_config.yaml
    • %exec_{number}[{index}]%
      • Retrieves the value at {index} from the array input to arg_{number}
    • %exec_{number}['{key}']%
      • Retrieves the value for {key} from the dictionary input to arg_{number}
    • %exec_{number}.{key}%
      • Retrieves the value for {key} from the object input to arg_{number}
  • arg_count
    • Increase or decrease the number of input items
  • normalization
    • Filename sanitization option
Retrieving node information connected to `arg_N`, using the node name, etc.
Retrieving `steps` and `sampler_name` from the `d2_pipe` object, which summarizes generation parameters.
Using the preset `a1111` with the value input to `arg_1`. Using `D2 Pipe` to add the checkpoint name.

D2 Prompt

  • You can select LoRA from the CHOOSE button and insert an A1111-style LoRA prompt
  • Delete comments in text
  • Targets lines starting with "#", lines starting with "//", and text between "/" and "/"
  • Displays token count at the bottom (works when token_count is true)
  • Uses "ViT-L/14" CLIP for token count measurement. Please use D2 Token Counter if you want to use other CLIP models

About Comment Shortcut Keys

  • Comment shortcut key (ctrl + /) is available in all text boxes
  • Shortcut keys can be changed in Settings > D2 > shortcutKey
  • Delete the content above if you want to disable it

D2 Prompt Sanitizer

  • A node that cleans up prompt strings
  • Converts _ (underscore) to a space (long_hair → long hair)
  • Ensures a single space after each , (comma) and tidies up surrounding whitespace (a , b → a, b)
  • Collapses redundant consecutive commas and removes commas at the start of a line (a,, ,b → a, b)
  • Each transformation can be toggled on / off individually

Input

  • underscore_to_space: Convert _ to a space
  • space_after_comma: Tidy the whitespace around commas and normalize it to , (line breaks are preserved)
  • remove_extra_comma: Collapse redundant consecutive commas (,, / , ,) into one and remove commas at the start of a line (line breaks are preserved)
  • protect_lora: Protect LoRA notation enclosed in <...> from conversion (keeps the underscores in <lora:my_lora:1>)
  • protect_score: Protect Pony quality tags such as score_9 / score_8_up from conversion

D2 Token Counter

  • Counts tokens in prompts