ComfyUI Node

Any to Float

Convert or fail quietly, never crash

By DemonAlone·Created 7 months ago·Updated 22 days ago· 3
Any to Float
  • input_any
  • FLOAT

The other half of the wildcard trick this pack leans on: where String To Any lets you sneak a value into wildcard territory, Any to Float pulls one back out - take anything, and if it's genuinely convertible to a floating-point number, output that number. If it isn't, the node's own behavior is to return None rather than blow up the run.

Why "fail to None" beats "crash outright"

A lot of ComfyUI graphs end up with a wildcard-typed value somewhere upstream - output from another pack's "Any" node, a value that traveled through this pack's own Any-to-Any Adapter, a loop variable of unknown type - that eventually needs to land in a strict FLOAT socket like a KSampler's cfg or denoise. A naive cast would throw and stop your run cold if the value turns out not to be numeric. This node is written to fail soft instead: no exception, just None coming out the other side. That's a real usability difference if you're building a workflow meant to be reused with varying inputs rather than one you're hand-babysitting every run.

The catch worth internalizing: None reaching this node's output doesn't mean the workflow is safe. It means this node didn't crash. Whatever consumes the float next - a sampler, a math node - still has to receive an actual number to do its job, and most of them will error the moment they get a None instead. This node buys you a cleaner failure point, not a guarantee the run finishes.

The input and output

  • input_any (optional, wildcard *) - whatever you've got.
  • Output: a single FLOAT, or None if the conversion wasn't possible.

How to install it

ComfyUI Manager: search DemonAlone-nodes-ComfyUI, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/DemonAlone/DemonAlone-nodes-ComfyUI

then restart. No dependencies, no models.

Common issues & troubleshooting

I got None and the next node errored anyway. That's expected - see above. This node prevents itself from crashing on a bad conversion, it doesn't guarantee the rest of the graph handles a missing value gracefully. Trace the value one step upstream (a Show Any-style debug node, if you have one installed) to confirm what actually arrived here before assuming this converter is broken.

The converted number looks wrong, not missing. If the input was, say, a string like "7.5", that should convert cleanly; something like "seven point five" won't. Check exactly what value is reaching this node - it can only convert things that are genuinely numeric in some form, not parse arbitrary text into a number.

Do I need this if my source already outputs FLOAT? No - wire straight through in that case. This exists specifically for wildcard-typed sources landing on a strict FLOAT input.

Which converter do I want - this, or Any to Integer? Match it to what the target input expects. Whole-number widgets (steps, batch size, seed) want Any to Integer; anything expecting a decimal (cfg, denoise, strength) wants this one.

Categoryutils

Inputs (1)

NameTypeDefaultDescription
input_anyopt*

Outputs (1)

NameTypeDescription
FLOATFLOAT