Skip to main content

To Number

Uncontrolled node

Overview

The To Number node converts any input value into a numeric value. This is useful when you need to ensure data is in number format for mathematical operations, comparisons, or when passing data to nodes that require numeric inputs.

The node uses JavaScript's standard number conversion logic. If the input cannot be converted to a valid number (e.g., empty strings, non-numeric text), the node outputs 0 as a fallback.

Inputs

InputTypeDescriptionDefault
ValueDataThe value to convert to a number. Accepts strings, booleans, or any data type that can be coerced to a number.-

Outputs

OutputTypeDescription
NumberDataThe numeric representation of the input value. Returns 0 if the conversion results in NaN (Not a Number).

Runtime Behavior and Defaults

As an uncontrolled node, To Number executes immediately whenever its input value changes. It does not require an event trigger to run.

The conversion follows these rules:

  • Strings: Parsed as decimal numbers (e.g., "42" becomes 42, "3.14" becomes 3.14)
  • Booleans: true becomes 1, false becomes 0
  • Numbers: Passed through unchanged
  • Invalid/Empty values: Converted to 0 (e.g., "hello", null, undefined, empty strings)

Example Usage

Converting Text Input to Numbers

Connect a Text node or Plain Text node to the Value input when you need to perform calculations on user input or text data:

[Text Node: "100"] → [To Number] → [Number output: 100]

Handling Form Data

When receiving numeric data from form elements that output strings, use To Number to ensure the data is properly typed before passing to mathematical nodes like Formula or Compare:

[Form Data: "price"] → [To Number] → [Formula: price * 1.2]

Safe Conversion with Fallback

If you have data that might occasionally be invalid or missing, To Number ensures you always get a usable number (defaulting to 0) rather than NaN or errors:

[Variable: "userCount"] → [To Number] → [Number output: 0] (if variable is undefined)