Nodes/KJNodes for ComfyUI/String Constant
ComfyUI Node Runs on cloud

String Constant

A single-line piece of text you can wire around your graph

By kijai·Created 3 years ago·Updated about 15 hours ago· 2,930
String Constant
    • STRING
    string

    String Constant is exactly what it sounds like: type a single line of text into it, and it outputs that text as a STRING you can wire into any node that accepts one. No processing, no formatting, no options beyond the text box itself.

    Why bother with a node this simple

    Because reuse is the whole point. The moment the same bit of text - a trigger word, a fixed filename prefix, an API key placeholder, a short tag you reference from two or three places - needs to live in more than one spot in your workflow, typing it directly into each consuming node's widget means you're maintaining N copies by hand. Change one, forget the others, and now your workflow is subtly inconsistent in a way that's easy to miss. Put the value here once instead, wire the output wherever it's needed, and updating it in one place updates it everywhere downstream automatically.

    It's also handy as a clearly-labeled, easy-to-find place to park a constant so anyone reading your workflow later (including future you) can see at a glance what value is being reused, rather than hunting through node widgets to find where a particular string originates.

    The inputs and outputs that matter

    • string (STRING, default empty, single-line) - the text itself.
    • STRING out - wire it to any string input elsewhere in your graph.

    If you need more than one line of text, or want the option to strip embedded newlines before output, reach for the sibling node String Constant Multiline instead - same idea, built for longer or multi-line text.

    Installing it

    Ships with the pack:

    • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, restart.

    Nothing to it beyond the base pack - no dependencies, no downloads.

    Common issues & troubleshooting

    Wondering why you'd use this instead of just typing text into the target node's own widget. For a value used exactly once, you probably wouldn't - a plain widget on the consuming node is simpler and this node would just be an extra hop. It earns its place the moment the same text needs to appear in two or more places in the graph.

    Pasted or typed text with line breaks and it's causing issues downstream. This node is single-line by design - if you need actual line breaks preserved, or want the option to strip them automatically, that's String Constant Multiline's job, not this one.

    Text isn't updating downstream after you changed it. Double-check the consuming node is actually wired to this node's output rather than having its own separate widget value that happens to look similar - if a node has its own local text field instead of an input wire, editing this node's string value won't touch it. The whole benefit only applies to nodes actually connected to the output.

    CategoryKJNodes/constants

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING