Skip to main content
Version: 7.9


This function is used by Ignition's Expression language..


Tries to convert value to a boolean, according to these rules:

  • If value is a number, 0 is false and anything else is true.
  • If value is a string, then the strings (case insensitive) "on", "true", "t", "yes", "y" are all true. The strings (case insensitive) "off", "false", "f", "no", "n" are considered false. If the string represents a number, the first rule applies. All other strings fail type casting.
  • All other types fail type casting.

If type casting fails, an error is thrown, unless the failover argument is specified, in which case it will be used.


toBoolean(value[, failover])

  • Parameters

    • object value - The value to type cast.

    • object failover - Optional. The failover value if type casting fails.

  • Results

    • Bool - The value type cast as a bool.


Code Snippet
toBoolean(1) //returns true
Code Snippet
toBoolean("abc", false) //returns false