to-bool

The to-bool operation converts the input value into a boolean (true or false). This is useful when you need a clear yes/no flag for conditions, routing, or API calls.

How it works

The following values are treated as false:

  • false (already boolean false)
  • 0 (integer zero)
  • 0.0 (float zero)
  • “” (empty string)
  • “0” (string containing zero)
  • [] (empty array)
  • null

All other values are treated as true, including:

  • Any non-zero number (positive or negative)
  • Any non-empty string (even “false” or “0.0”)
  • Any non-empty array
  • Any object or resource

Examples

InputResult
falsefalse
truetrue
0false
-1true
0.0false
“0”false
“false”true
“hello”true
[]false
[0]true
nullfalse

Usage in PalDock

Use to-bool when you need to:

  • Normalize form inputs (e.g., interpret checkbox-like fields as true/false).
  • Guarantee a boolean value before a Condition or Router element.
  • Send proper boolean values in API requests (true/false instead of text or numbers).

Best Practices

  • Remember that the string “0” is the only non-empty string treated as false.
  • The string “false” is considered true (because it is non-empty). If you need to handle “true”/”false” text literally, normalize the string first.
  • Empty arrays are false; arrays with at least one item are true.

References

https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.castinghttps://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting

Related articles

Modify Field > combine
Modify Field > urldecode
Modify Field > urlencode
Modify Field > load-from-lead
Modify Field > regex-replace
Modify Field > from-base64
Modify Field > to-base64
Modify Field > modify-date
Modify Field > format-date
Modify Field > do-not-send

Insights that
helps you grow