--- title: "toBoolean" description: "Tries to convert value to a boolean" --- # toBoolean > Tries to convert value to a boolean **This function is used by Ignition's Expression language**. ## Description Tries to convert value to a boolean, according to these rules: 1. If value is a number, 0 is false and anything else is true. 2. 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. 3. 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. ## Syntax `toBoolean(value[, failover])` ### Parameters | Type | Parameter | Description | |---|---|---| | object | `value` | The value to type cast. | | object | `failover` | The failover value if type casting fails. [optional] | ### Results **Bool** - The value type cast as a bool. ## Examples ```python title="Code Snippet" toBoolean(1) //returns true ``` ```python title="Code Snippet" toBoolean("abc", false) //returns false ```