Nodes/comfyui-darkil-nodes/Constant Setter [darkilNodes]
ComfyUI Node

Constant Setter [darkilNodes]

One node that outputs any constant type — and converts whatever you feed it

By pytraveler·Created 7 months ago·Updated 15 days ago· 9
Constant Setter [darkilNodes]
    • value

    Every ComfyUI graph eventually needs "a number that I can tweak," and you usually end up with three separate nodes for int, float and boolean. This node collapses that into one: a ConstantSetter whose type you configure, with a wildcard value output that can be a string, an int, a float, a boolean, a combo selection, or a slider/knob. The kicker is the input_enable option - flip it on and the node stops being a constant and becomes a type converter, taking whatever you feed it and coercing it to the configured type.

    How it works

    The node has no required inputs in its schema at all; all configuration lives in node properties (the gear/pencil UI that ComfyUI shows for configured nodes), passed in as a JSON blob. You set:

    • const_type - STRING, INT, FLOAT (or FLOAT2FLOAT5 for decimal places), BOOLEAN, COMBO, SLIDER (or SLIDER2SLIDER5), KNOB (or KNOB2KNOB5).
    • default_value - the constant.
    • minimum / maximum - range bounds for numeric and slider/knob types; slider values get clamped.
    • values - a semicolon-separated list for COMBO.
    • input_enable - whether the node exposes an input socket for value conversion.

    When input_enable is on and an input arrives, the node converts it: strings to int via floor, booleans via the usual true/1/yes parsing, floats to the requested precision, combos validated against the list. When there's no input, it just emits the configured constant. It's marked as a virtual node, so it doesn't bloat your serialized prompt with hidden state.

    The output

    Exactly one: value of type * (wildcard). That's what makes it handy - you can feed it into an int slot, a float slot, a string slot, or even a combo slot without fighting type errors, as long as the conversion makes sense. If the conversion fails, it logs a warning and falls back to the default rather than crashing your queue.

    Where people get burned

    The trap is forgetting which mode you're in. A node you set up as a constant starts silently converting whatever you connect to it once input_enable is on - and because the output is a wildcard, ComfyUI won't complain when the coercion produces something unexpected. Also, sliders clamp to minimum/maximum and ints floor rather than round, so if your 0.6 becomes 0, that's the floor behavior working as designed, not a bug.

    Installing

    It's part of pytraveler/comfyui-darkil-nodes. ComfyUI Manager search ComfyUI-darkil-nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/pytraveler/comfyui-darkil-nodes
    

    Restart ComfyUI. No Python deps, no model files - it's a pure logic node.

    CategorydarkilNodes/logic

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    value*