# Converting between data types

When passing data from one step to another, sometimes you will need to convert the data type of certain values.

##

When passing data from one step to another, sometimes you will need to convert the data type of certain values.
Commonly this is when a destination service has certain type requirements (strings v numbers, objects v arrays, booleans etc.) which the source of your data does not meet.

## Strings / Numbers

If a number has been returned as a string you may need to convert it to a number in order to satisfy the requirements of your destination service. Or vis versa.
In this case we can use the [Text Helpers](https://tray.ai/documentation/connectors/helpers/text-helper/) \*\*Change type \*\*operation:
![typecast-to-number](https://tray.ai/documentation/images/platform/automation-integration/building-workflows/mapping-data/converting-between-data-types/658uSkuwKbroCYGb9Iob6i_asdljf.png)
![typecast-outputs](https://tray.ai/documentation/images/platform/automation-integration/building-workflows/mapping-data/converting-between-data-types/499lufsZvIbJRhePrbsbca_Group%2022.png)

## Arrays

If we have a case of a simple list of values that need to be converted to an array:

```json
\{
  "value": "123, 111, 444"
\}
```

We can use the **Text Helpers 'split'** operation, set to 'split by' a comma:

![text-helpers-split-array-by-comma](https://tray.ai/documentation/images/platform/automation-integration/building-workflows/mapping-data/converting-between-data-types/1tQeJR0JvLTHTZN2POTSbE_text-helpers-split-array-by-comma.png)
![text-helpers-split-outputs](https://tray.ai/documentation/images/platform/automation-integration/building-workflows/mapping-data/converting-between-data-types/21CRZbcsxT289xaEGVYXYy_text-helpers-split-outputs.png)
Note however that each item in the array is a string.

We could also use the **Object helpers 'JSON parse'** operation to create an entirely new JSON object and use square brackets to return an array.
This will return an array of numbers:

![object-helpers-parse-as-array](https://tray.ai/documentation/images/platform/automation-integration/building-workflows/mapping-data/converting-between-data-types/7luWbjPhbfflExVXiyUdTM_object-helpers-parse-as-array.png)
![object-helpers-parse-array-outputs](https://tray.ai/documentation/images/platform/automation-integration/building-workflows/mapping-data/converting-between-data-types/7bijgpXStzPVBBbbneh5km_object-helpers-parse-array-outputs.png)

## Booleans

If you need to convert a String `"true"` or `"false"` into an actual boolean, once again you can use the **Text Helpers 'Typecast'** connector.
If you are using the [Boolean Connector](https://tray.ai/documentation/connectors/core/boolean-condition) to compare, you can actually perform the type conversion within the connector itself - just ensure that the 1st and 2nd values are set to the same data type:
