Nodes/ComfyUI-FString/Simple F-String
ComfyUI Node

Simple F-String

Make ComfyUI write the sentence for you

By danielwolber-wood·Created 8 months ago·Updated 8 months ago· 0
Simple F-String
    • formatted_string
    templateThe value of x is {x}

    ComfyUI is a graph of numbers, tensors, and model names - most of it invisible while you work. Simple F-String is the little node that lets you turn all that data into a sentence. Wire a seed, a CFG, a model name, or anything else into it, type Processing with {model} using seed {seed} into the template box, and out comes a clean string you can feed to a filename node, a text display, or a prompt.

    It's the glue work that text nodes do in almost every serious workflow, except you don't have to write a custom node or hardcode values. And despite the name, it's not actually Python f-strings under the hood - it's Python's .format() syntax, which gives you the same {placeholder} behavior with a few fewer edge cases. The name is a small lie; the convenience isn't.

    How it works

    The node itself is pure Python plus one tiny JavaScript file. The template input is a multiline string box; every other input is dynamic. Right-click the node and you get Add Input (Variable) and Remove Last Input - that's the JS doing the work, prompting you for a name and adding a wildcard input that accepts any type of connection.

    When the graph runs, format_inputs catches every dynamic input as a keyword argument and cleans it up:

    • None becomes the string "None" instead of crashing.
    • Anything with a .shape - i.e. tensors - becomes something readable like Tensor torch.Size([1, 512, 512, 3]). That's genuinely handy when you want to log what's actually flowing through your graph.
    • Everything else is converted with str().

    Then it runs Python's template.format(**values). If a placeholder doesn't match any connected input, you don't get a crash - you get an error string returned as the output, which is friendlier than a broken graph. The same string also gets printed to your ComfyUI console with a [DEBUG F-String] tag on every run, which gets old fast.

    The inputs that matter

    • template - the only required input. A multiline text box where you write your string with {placeholder} markers. The defaults are sensible: The value of x is {x}.
    • Dynamic inputs - added via the right-click menu. The name you type in the prompt is the placeholder you use in the template, so {seed} requires an input literally named seed. Keep names single words with no spaces; {my seed} won't format cleanly and you'll get an error string back.
    • formatted_string - the single output. It's a plain STRING, so it wires into anything that takes text: filename/date nodes, text displays, prompt conditioning, metadata.

    Installing it

    Install via ComfyUI Manager (search for ComfyUI-FString) or clone it directly:

    cd ComfyUI/custom_nodes
    git clone https://github.com/danielwolber-wood/ComfyUI-FString.git
    

    Then restart ComfyUI. That's it - there's no requirements.txt, no model downloads, no GPU dependency. The whole pack is one Python file and one JS file, which makes it about as safe and lightweight as custom nodes come in an ecosystem where that's not always the case.

    Where people get tripped up

    • Input names must match placeholders exactly. Type seed_value in the prompt but {seed} in the template and you get an Error: Template uses {seed} but that input doesn't exist! string instead of output. The node's error handling saves you from a hard failure, but it's not a mystery - re-check the names.
    • "Remove Last Input" only removes the last one. There's no per-input delete, so if you add five and want to remove the second, you're removing in reverse order. Minor, but it's the fiddliest part of the UX.
    • Search under the right category. The README says Learning/Text; the shipped code puts it under DLWW/Text. If you're hunting for it in the node menu, check both.
    • That console spam. Every run prints the formatted result to the terminal. Harmless, but noticeable in long batches.

    It's a small tool, and its zero-impression page reflects that - nobody's shouting about this node, and you don't need them to. When you need a filename with the seed baked in or a readable label for what your workflow just did, it just works.

    CategoryDLWW/Text

    Inputs (1)

    NameTypeDefaultDescription
    templateSTRINGThe value of x is {x}

    Outputs (1)

    NameTypeDescription
    formatted_stringSTRING