Nodes/ComfyUI Smart Helper Nodes/Smart Format String
ComfyUI Node

Smart Format String

A format string node with %1 params and a clock that actually updates

By slvslvslv·Created 2 years ago·Updated about 9 hours ago· 3
Smart Format String
  • param_1
  • param_2
  • param_3
  • param_4
  • param_5
  • formatted_string
string_formatValue is: %1

Every ComfyUI regular eventually ends up hand-rolling a "build a string from a few values" node. Smart Format String is the tidy version: you write a template like Value is: %1 and it swaps in your parameters, plus it understands %H/%M/%S/%y/%m/%d as the current date and time. That last bit is the sleeper feature - and the reason this node re-runs even when nothing else changed.

How it works

The template lives in the string_format input. On execution it replaces the time placeholders first - %H is hours (00–23), %M minutes, %S seconds, %y two-digit year, %m month, %d day - then swaps %1 through %5 with your param_1param_5 inputs. Parameters are replaced in reverse order, which is the correct way to avoid %1 eating the front of %10 in format-string land (with five params you're unlikely to trip it, but the author built the 10-param sibling on the same logic).

The important detail is in the re-evaluation logic: if your template contains any time placeholder, the node reports itself as changed on every run. That means the timestamp actually updates. Without it, ComfyUI would cache the result and your "rendered at %H:%M:%S" would freeze at the first render's time - the classic timestamp-node bug this one dodges.

The inputs are any-typed, so you can wire a seed int, a width, a LoRA strength, a filename - anything that stringifies - into the params. Output is a single formatted_string.

Where it's useful

The obvious home is filenames. Build a save path like render_%y%m%d_%H%M_%1.png with your seed in param_1, and every render gets a unique, timestamped name without you touching the file widget. It also pairs naturally with the rest of the pack: compose a header line with date and parameters, feed it into SmartSaveText, and you've got a run log.

Installing it

It ships in SmartHelperNodes; install once:

cd ComfyUI/custom_nodes
git clone https://github.com/slvslvslv/ComfyUI-SmartHelperNodes

Restart ComfyUI, or use ComfyUI Manager ("SmartHelperNodes"). No pip dependencies, no downloads.

Common issues

Two things to keep straight. First, the time placeholders use your local machine time, not UTC - fine for filename stamps, confusing if you expected a fixed timezone. Second, the always-re-evaluates behavior is a feature for timestamps but means a format string with %H in it will keep the node "dirty" in caching terms; that's the price of a live clock and it's worth it. And if you leave a %1 placeholder with no parameter wired, it comes out as an empty string rather than an error - usually harmless, occasionally the cause of a mysteriously blank filename.

CategorySmartHelperNodes

Inputs (6)

NameTypeDefaultDescription
string_formatSTRINGValue is: %1Format string with: %1-%5 for parameters %H for hours (00-23) %M for minutes (00-59) %S for seconds (00-59) %y for year (00-99) %m for month (01-12) %d for day (01-31)
param_1opt*
param_2opt*
param_3opt*
param_4opt*
param_5opt*

Outputs (1)

NameTypeDescription
formatted_stringSTRING