Nodes/comfy-ovum/Python String Format
ComfyUI Node

Python String Format

The most useful text node in comfy-ovum

By sfinktah·Created about a year ago·Updated 10 months ago· 7
Python String Format
    • text
    fmt

    If you ever build a prompt, a filename, or a caption inside a workflow, this is the Ovum node worth knowing first. Python String Format takes a format template and injects values into it using Python's own str.format syntax - the same {arg0} placeholders you'd use in a Python string. It sounds modest. Then you wire in a seed, a steps value, and a checkpoint name, and suddenly every dynamic string in your graph has a home.

    The author's framing is that this is the node that shouldn't kill your workflow at the worst moment - and it genuinely doesn't. Most formatting nodes in the ecosystem blow up when an upstream value goes missing or a format spec is wrong. This one is built to fail soft.

    How it works

    Type a template in the fmt field using {arg0}, {arg1}, and so on for the first, second, and subsequent inputs. As you reference placeholders, matching input slots appear on the node. Python's full format syntax is available, so you can do:

    Score: {arg0:.2f}  Image_{arg1:04d}  [{arg2:^20}]  {arg3!r}
    

    That's float precision, zero-padded integers, centered alignment, and repr conversion, all in one line. Newlines work too - hit Enter in the template and the line break lands in the output, or use \n explicitly for multi-line prompts.

    Two behaviors separate this from the crowd:

    • Missing values become "None", not a crash. Internally the node formats with a _SafeDict that returns a literal None for any placeholder with no value, so a disconnected input or an empty generator just shows up as the text "None".
    • Non-scalars stay real objects. Lists, dicts, and tuples are passed through as actual Python objects rather than flattened to JSON strings. That means you can index straight into them: Top tags: {arg0[0]}, count={arg0[2]:02d} works, and so does {arg0[name]} on a dict.

    If something genuinely can't be formatted - a bad spec, an out-of-range index - the node prints the error to the console and returns the error text as the output string. Your run keeps going. That alone is why people switch to it for long renders.

    The inputs that matter

    • fmt - the only required input in the schema: your format template. Multiline, and the tooltip tells you everything: "Use {arg0} to insert the first input, {arg1} for the second, etc. Anything that works in python's .format works here."
    • arg0, arg1, … - dynamic inputs that appear as you use their placeholders. Wire anything in; scalars, lists, dicts all work.
    • Output: text - a single STRING.

    Installing it

    It's part of sfinktah/comfy-ovum. In ComfyUI Manager, search comfy-ovum, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sfinktah/comfy-ovum
    

    Then restart. No models, no heavy deps - the pack's requirements are a few small pure-Python helpers. You'll find the node by typing Python String Format or just ovum.

    Where it's fiddly

    Escaping literal braces takes a beat to remember: {{ and }} produce one brace each. And because missing values render as the string "None", a value that never arrives won't error but will silently read "None" in your filename - worth knowing before you save frame_None.png and hunt for it later. That's the trade for never crashing; it's a good one.

    Categoryovum

    Inputs (1)

    NameTypeDefaultDescription
    fmtSTRINGA python format string. Use {arg0} to insert the first input, {arg1} for the second, etc. Anything that works in python's .format works here.

    Outputs (1)

    NameTypeDescription
    textSTRING