Nodes/ComfyUI-HttpRequestNodes/String Replace Node
ComfyUI Node

String Replace Node

Turn one template into a hundred requests without touching the URL again

By ahkimkoo·Created 3 months ago·Updated 3 months ago· 1
String Replace Node
  • placeholders
  • output_string
input_string

The String Replace Node is the template engine of ComfyUI-HttpRequestNodes. You give it a string with placeholders and a dictionary of values, and it swaps every placeholder out for its value. It's the node that turns a hardcoded URL like https://api.example.com/models/foo into a URL whose foo changes per run - which, when you're building API calls across a workflow, is the difference between rewriting nodes and reusing them.

It's small, it's dumb, and that's exactly its strength. It pairs with a Key/Value Node (which builds the KEY_VALUE dict of replacements) and sits upstream of any request node's target_url or request_body - including the Post Request Node, which also has its own built-in __str0__ placeholders if you'd rather not use a separate node.

How it works

Two inputs: input_string (a multiline text box) and placeholders (a KEY_VALUE dict, optional). The mechanism is plain str.replace under the hood - the node iterates the dict and replaces each key with its value, in order. So input_string = "GET /users/{id}" with placeholders = {"{id}": "42"} comes out "GET /users/42".

Three things follow from it being plain replace:

  • It's literal, not regex - no fancy patterns, no escaping rules to learn.
  • If no placeholders are wired, the input passes through untouched, so the node is safe to leave in place.
  • Replacement order matters if values overlap - {"a": "b", "ab": "c"} will replace a before ab even gets a chance. Keep placeholder names distinct.

The output is a single output_string socket, ready for any URL or body input in the pack.

When you'd actually use it

Build URLs with query strings from a Key/Value node, or template a JSON body once and swap the moving parts per run - the Rest Api Node example workflow in this pack uses exactly this pattern (a couple of String Replace nodes feeding the request). If you're doing a lot of this, you'll eventually want something with wildcard syntax and a real template language, but for "one URL, one variable" this is the lightest thing that works.

Install

ComfyUI Manager → search ComfyUI-HttpRequestNodes → Install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/ahkimkoo/ComfyUI-HttpRequestNodes
pip install soundfile imageio imageio-ffmpeg

Category: RequestNode/Utils. No dependencies beyond ComfyUI core. This is pure string plumbing - there's genuinely nothing to go wrong with the install.

CategoryRequestNode/Utils

Inputs (2)

NameTypeDefaultDescription
input_stringSTRING
placeholdersoptKEY_VALUE

Outputs (1)

NameTypeDescription
output_stringSTRING