Shima Transformer
A tiny 'key ||| value' router that actually remaps values
- in_1
- in_2
- in_3
- in_4
- var_!!!
- var_@@@
- var_###
- var_$$$
- out_1
- out_2
- out_3
- out_4
Despite the name, Shima Transformer has nothing to do with transformers, diffusion, or attention. It's a small conditional-mapping node - the kind of "graph as a small program" utility that ComfyUI's wildcard type system exists to enable. You give it up to four inputs, write a mapping rule for each, and it remaps values into whatever you need downstream. Think of it as an if/else you can type instead of wire.
How the mapping works
Each channel pairs an in_1..in_4 input with a map_1..map_4 multiline text box. Each line of the map is a rule:
key ||| value- if the input equalskey, outputvalue- A line with no
|||is a catchall - it replaces any input immediately, no matching - If no line matches, the input passes through unchanged
Rules are evaluated top to bottom, first match wins. And because matching happens on the string form of the input, "2", 2, and True all become text to compare - with one nice touch: booleans do loose matching, so a True input matches a map line written as true, True, or 1.
Here's a real example. Say you have a node that outputs a seed as a string and you want to convert it into three typed values:
1 ||| true
0 ||| false
Feed that to one channel and "1" becomes a real boolean True instead of the literal text. The infer_type step auto-casts true/false to booleans and digit strings to int/float, so "42" comes out as the integer 42. Flip output_as_strings on and it stops casting - every output stays literal text, which you want when you're building filenames or prompts and don't want "0.0" turned into 0.
The variable injection trick
The one feature that makes this more than a lookup table: var_!!!, var_@@@, var_###, var_$$$. Wire any values in there and reference them inside a map value with !!!, @@@, ###, $$$. So a catchall line like:
Hello, @@@ ! You got ###.
pulls the current user name and batch number from other nodes and bakes them into the output string. It's a poor man's f-string for ComfyUI, and it's genuinely handy for templating.
The inputs and outputs
output_as_strings(required) - force all outputs to stringsin_1..in_4+map_1..map_4- four independent channelsvar_!!!..var_$$$- injection tokens, optional- Outputs:
out_1..out_4- the remapped values (type depends on what matched andoutput_as_strings)
Every channel is independent, so you can use one for a boolean remap and another for a filename string and a third for nothing. Channels with an empty map are pure pass-throughs.
Installing and gotchas
It ships in the Shima pack (KDB-USJP/shima_wf): ComfyUI Manager → search "Shima", or git clone https://github.com/KDB-USJP/shima_wf into custom_nodes, then restart. The pack auto-installs cg-use-everywhere and Impact-Pack on first run.
Where people get burned: the map matching is per-channel, so a rule in map_1 never affects in_2 - a common first-time mistake when you copy a workflow. Also, remember a line with no ||| is an unconditional override; if you paste a multi-line value and forget the delimiter, everything gets clobbered by the first line. And if your output comes back as a string when you expected a number, you forgot that a matched empty value (key |||) passes the input through rather than producing an empty string - that's a deliberate design quirk, not a bug.
Reach for it when you need a mid-graph value remap without adding a whole logic pack. It's the utility in this pack that earns its place.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| output_as_strings | BOOLEAN | false | — |
| in_1opt | * | — | |
| map_1opt | STRING | — | |
| in_2opt | * | — | |
| map_2opt | STRING | — | |
| in_3opt | * | — | |
| map_3opt | STRING | — | |
| in_4opt | * | — | |
| map_4opt | STRING | — | |
| var_!!!opt | * | — | |
| var_@@@opt | * | — | |
| var_###opt | * | — | |
| var_$$$opt | * | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| out_1 | * | — |
| out_2 | * | — |
| out_3 | * | — |
| out_4 | * | — |