Nodes/ymc-node-as-x-type/set it as string type
ComfyUI Node

set it as string type

A STRING sticker for text that's been wandering through any-wires

By YMC-GitHub·Created 2 years ago·Updated about a year ago· 0
set it as string type
  • a
  • String

Text is the sneakiest value in ComfyUI. A STRING looks harmless, but it's the thing people push through the most convoluted plumbing - a prompt built by a switch, a tag pulled from an API, a positive that gets routed to three different encoders. Somewhere along that journey it almost always passes through an any-typed junction, and then the editor forgets it's a string. "Set it as string type" is the way back.

Same mechanism as every node in this pack, and it bears repeating once: exec(self, a=None): return (a,). The value on a passes through untouched, and RETURN_TYPES = ("STRING",) re-declares it, so the output plugs into a prompt input on a CLIP Text Encode, a text box, or a node that wants a string socket. No encoding, no trimming, no conversion. It's a label that says "this is text, trust me."

The honestly useful bit about this specific variant: strings are where the "trust me" model is least dangerous. If you stamp a number as a string, the downstream node that joins it onto a prompt will usually just stringify it and carry on - the failure mode is mild compared to mislabeling a conditioning or a latent, where the crash is loud and confusing. That makes this one of the pack's lower-stakes nodes, which is a nice thing to be able to say about any ComfyUI helper.

When you'd reach for it

  • A primitive or API value arrives as * and a prompt input insists on STRING.
  • You're assembling prompts via switch/any-routing and want a typed output to hand to a text encoder.
  • The README's stated case - enhancing cg-use-everywhere routing - applies to text more than most.

If your strings travel directly from a Text node to a text encoder, you don't need it. If they've been through the plumbing, this is a cheap way to straighten them out.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/YMC-GitHub/ymc-node-as-x-type

or via ComfyUI Manager (search ymc-node-as-x-type), restart. No models; the four yors_* pip deps auto-install on startup. Find it by double-clicking and typing set it as, or right-click → YMC → LINK.

Gotchas

  • It's a label, not a serializer - what's on the wire is what the next node gets.
  • From the usual one-commit, single-maintainer pack (v0.1.2). Works as shipped; don't expect updates.
CategoryYMC/LINK

Inputs (1)

NameTypeDefaultDescription
aopt*

Outputs (1)

NameTypeDescription
StringSTRING