Nodes/Placeholder-Replacer-By-ID/Placeholder Replacer By ID
ComfyUI Node

Placeholder Replacer By ID

Swap [a1] for a real artist name across a whole batch of prompts

By anhrefnyoiyoi·Created 10 months ago·Updated 10 months ago· 0
Placeholder Replacer By ID
  • id_sequences
  • resolved_prompts
  • debug_info
  • primary_ids
prompt_list
term_mappings
mirror_first_promptfalse
auto_step_idsfalse
manual_idsfalse
mirror_first_idfalse
manual_ids_list
increment_base
placeholder_token[a1]
prompt_delimiter;;;;;

You've got twenty artist IDs, a prompt template that says [a1] in watercolor style, and exactly zero interest in hand-writing twenty variations. That's the whole pitch of Placeholder Replacer By ID: a tiny text-utility node that swaps a literal placeholder token like [a1] for the artist name a number maps to. No API, no LLM, no model files, no key. It's pure string surgery done inside the graph, and it's a surprisingly handy thing to have when you're batch-testing styles.

The use case that makes it click: you're sampling the same base prompt across a roster of artists - [a1] in watercolor style, [a1] in oil-painting style, [a1] portrait study - and you want each of those to render with a different artist name on each run. Feed it a mapping like 1_van_gogh, 2_monet, 3_vermeer, give it an ID sequence, and it resolves every slot for you. It's the deterministic cousin of wildcard systems: instead of picking randomly from a list, it picks by the ID you hand it, so the same workflow run again produces the same batch.

How it works

Mechanically it's dead simple, which is the appeal. prompt_list is split into slots by a delimiter (default ;;;;;). Your id_sequences is split into one ID per slot. term_mappings is parsed line by line as ID_name, split on the first underscore - so 21_shigenori_soejima is fine, but the number always has to come first. Then, for each slot, the placeholder token is replaced with the name mapped to that slot's ID, and everything is re-joined with ;;;;;.

There are three ways the ID for a slot gets decided. Normal mode just takes the next ID from id_sequences. Auto-step ignores the list and generates base, base+1, base+2… from increment_base - handy when your artists are numbered sequentially and you don't want to type the list. Manual mode overrides everything with manual_ids_list, and if you've got more prompt slots than manual IDs, the leftover slots get the literal string NOT_FOUND rather than erroring out. There are also two mirror toggles: mirror_first_prompt runs the first template for every slot, and mirror_first_id copies the first ID to all of them. That mirror-first-prompt toggle is the one I'd actually reach for - same prompt, every artist in your roster, one run.

The inputs and outputs that matter

You'll set three things almost every time: prompt_list (your templates, ;;;;;-separated), term_mappings (your ID_name lines), and id_sequences (your IDs). The rest are defaults you reach for only when you need them - placeholder_token defaults to [a1], so you can rename the token if your templates collide, and prompt_delimiter splits the templates if you don't like semicolons.

Outputs are three strings: resolved_prompts (all slots joined with ;;;;;), debug_info (a log of what it parsed and applied - useful when a batch comes out wrong), and primary_ids (a ;-separated ID_name list that's handy as a wiring label). Note resolved_prompts comes back as one big string; if each slot needs to go into its own CLIP text encode, split it back apart with a string-splitter node from a pack like WAS Node Suite.

Install

It's in ComfyUI Manager - search "Placeholder-Replacer-By-ID" and hit install, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/anhrefnyoiyoi/Placeholder-Replacer-By-ID

Restart ComfyUI. There's no requirements.txt and nothing to download - the whole node is one file of standard-library Python. This is the rare custom node that can't drag your environment into dependency hell.

Gotchas

  • Only the first ID per slot gets used. If you feed an id_sequences list longer than your prompt count, the extra IDs sit unused. That's by design, but it trips people up.
  • term_mappings split on the first underscore, so a mapping with no number at the front (like a name starting with a digit) silently vanishes.
  • Manual IDs are ;-separated only. parse_manual_ids is pickier than the main ID parser - paste 1,3 and you'll get nothing but NOT_FOUND slots. Use 1;3.
  • If an ID has no mapping, the placeholder is replaced with an empty string - the token just disappears from the prompt. That's usually what you want; if it's not, it's the debug_info output that tells you which slot went wrong.

It's a niche little node, and honestly it's the sort of thing you could script in a text editor. But once it's wired into a workflow that you re-run with different artist rosters, it saves a genuinely boring hour of copy-pasting - and it never calls out to anything, so it's safe and offline.

CategoryUtils

Inputs (11)

NameTypeDefaultDescription
id_sequencesINT_LIST
prompt_listSTRING
term_mappingsSTRING
mirror_first_promptBOOLEANfalse
auto_step_idsBOOLEANfalse
manual_idsBOOLEANfalse
mirror_first_idBOOLEANfalse
manual_ids_listSTRING
increment_baseINT
placeholder_tokenSTRING[a1]
prompt_delimiterSTRING;;;;;

Outputs (3)

NameTypeDescription
resolved_promptsSTRING
debug_infoSTRING
primary_idsSTRING