Convert
Converts all elements in an array to a specified data type (string, number, or boolean).
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Array - The array containing elements to convert.
Options
- To - The target data type for conversion. Available options:
- String - Converts all elements to string values
- Number - Converts all elements to numeric values
- Boolean - Converts all elements to boolean values
Outputs
- Array - The array with all elements converted to the specified type.
How It Works
The Convert node transforms all elements in an array to a specified data type. When executed, the node:
- Receives an array through the Array input
- Validates that a target type is selected
- Iterates through each element in the array
- Converts each element to the specified type:
- String conversion: Converts any value to its string representation
- Number conversion: Parses strings and converts to numeric values
- Boolean conversion: Converts valid boolean representations to true/false
- Returns a new array with all converted elements
- Handles thread-safe operations when working with Global or Flow scope variables
Requirements
- Valid array as input
- Target type must be selected (String, Number, or Boolean)
Error Handling
The node will return specific errors in the following cases:
- Invalid array input
- No target type selected: "Type must be selected"
- Conversion failure for specific elements:
- Number conversion: "cannot convert (value) into a number" - when the element cannot be parsed as a number
- Boolean conversion: "cannot convert (value) into a bool" - when the element is not a valid boolean representation
Boolean Conversion Rules
For boolean conversion, elements must be one of the following values (case-insensitive):
- True values: "1", "t", "true"
- False values: "0", "f", "false"
Any other value will cause a conversion error.
Usage Examples
Example 1: Convert Scraped Prices to Numbers
Convert price strings scraped from a website to numbers for calculations:
- Input Array:
["19.99", "25.50", "12.75", "8.99"] - Set To option to "Number"
- Result:
[19.99, 25.50, 12.75, 8.99] - Now you can perform mathematical operations on the prices
Example 2: Convert Numbers to Strings for Display
Convert numeric IDs to strings for concatenation or display:
- Input Array:
[1001, 1002, 1003, 1004] - Set To option to "String"
- Result:
["1001", "1002", "1003", "1004"] - Use for creating formatted messages or reports
Example 3: Convert Status Flags to Booleans
Convert string status values to boolean flags:
- Input Array:
["true", "false", "1", "0", "t", "f"] - Set To option to "Boolean"
- Result:
[true, false, true, false, true, false] - Use for conditional logic and filtering
Example 4: Data Normalization Pipeline
Normalize mixed-type data for consistent processing:
- Scrape form inputs that come as strings:
["25", "30", "18", "45"] - Convert to Number for age validation and calculations
- Process numeric data (e.g., calculate average age)
- Convert back to String if needed for output formatting
Tips for Effective Use
- Always validate your data before conversion to avoid errors
- String conversion is the most forgiving - any value can be converted to string
- Number conversion will fail if the string doesn't represent a valid number
- Boolean conversion requires exact values - use data validation first
- Use Continue On Error cautiously with Convert - a single invalid element will fail the entire conversion
- Consider using Array.GetElement in a loop for element-by-element conversion with custom error handling
- Combine with filtering nodes to remove invalid elements before conversion
- Use after data scraping operations to normalize data types
- Chain multiple Convert nodes for complex data transformations
Common Use Cases
- Converting scraped text data to numbers for calculations
- Normalizing form input data types
- Preparing data for database insertion with specific type requirements
- Converting numeric codes to strings for display
- Standardizing boolean flags from various sources
- Data type normalization in ETL (Extract, Transform, Load) processes
- Converting API response data to required types
- Preparing data for Excel or CSV export with consistent types
Common Errors and Solutions
Error: "cannot convert (value) into a number"
Cause: The array contains non-numeric strings like "abc", "N/A", or empty strings.
Solutions:
- Filter out non-numeric values before conversion
- Use data validation to clean the array
- Replace invalid values with defaults (e.g., 0) before conversion
Error: "cannot convert (value) into a bool"
Cause: The value is not one of the accepted boolean representations.
Solutions:
- Ensure values are "1", "0", "true", "false", "t", or "f" (case-insensitive)
- Use data transformation to map custom values to valid boolean strings first
- Example: Map "yes"/"no" to "true"/"false" before conversion
Error: "Type must be selected"
Cause: The To option was not set.
Solutions:
- Select one of the three target types: String, Number, or Boolean