How to Create an Array From a String Using Power Automate?

When working in Power Automate, you often need to manipulate data to meet your requirements, and strings are no exception. Have you ever had a scenario where you have a long string of values but must treat them as individual items?

Recently, I was working with a client, and I needed to create an array from a string. I found that we can create an array from a string using different functions, such as array(), createArray(), and split() functions.

In this tutorial, I will show you how to create an array from a string using Power Automate using these above functions.

Create an Array From a String Using Power Automate

Suppose you have a string containing email addresses separated by commas (e.g., [email protected], [email protected], [email protected]). You need to split this string into an array to loop through each email address and send a personalized message.

Create an Array From a String Using array() Function in Power Automate

In Power Automate, Array() creates or works with a list of values. Think of an array as a list of items grouped, such as numbers, names, or objects.

Syntax:

array(item1, item2, item3, ...)

Here, we will see how I create an array from a string with the help of the array() function.

1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

power automate string to array

2. Add an “Initialize variable” action, provide a name for the variable, set the type to “String,” and enter the following value in the “Value” field:

[email protected], [email protected], [email protected], [email protected], [email protected]
convert string to array power automate

3. Next, add compose action and provide the below expression:

array(variables('varEamil'))
string to array power automate

Now, click on save and run the flow manually. After the flow runs successfully, click the compose action to see the Output section.

Create an Array From a String Using array() Function in Power Automate

Create an Array From a String Using createArray() Function in Power Automate

The Power Automate createArray() function creates an array (a collection of items, like a list) from individual values. Think of it as a way to group multiple things in one place so you can work with them as a single collection.

The syntax for the createArray() function in Power Automate is:

createArray(value1, value2, value3, ...)

Suppose you manage a Power Apps application and must send individual notifications to a predefined list of users whenever a specific event occurs (e.g., when a new record is added to a SharePoint list). Instead of maintaining a separate list, you can use Power Automate’s createArray() function to define these users directly.

This is the SharePoint I used for this example:

power automate convert string to array

Now follow the below steps:

1. Create an automated cloud flow. Give the flow name and select the trigger When an item is created. Also, provide the Site Address and List Name.

power automate create array from string

2. Add a Compose action to create an array of email addresses (users to notify).

createArray('[email protected]', '[email protected]', '[email protected]')
convert string to array in power automate

3. Add an Apply to Each action to process each user in the array.

  • Input: Use the output of the Compose action as the input to the loop.
power automate strings to array

4. Inside the loop, add the Send an Email (V2) action to send a notification to each user and provide below parameters:

  • To: Use the dynamic content Current item from the Apply to Each action.
  • Subject:
New Support Request Added 
  • Body: Include details from the SharePoint list, such as:
A new support request has been added: 


Title: @{triggerBody()?['Title']} 
Description: @{triggerBody()?['Description']}
Priority: @{triggerBody()?['Priority/Value']}
power automate string array

Now, it’s time to save the flow. Click on Test -> Select Manually. Add an item to the SharePoint list.

how to convert string to array in power automate

After the flow runs successfully, people get notified about the new support request.

Create an Array From a String Using createArray() Function in Power Automate

Create an Array From a String Using split() Function in Power Automate

In Power Automate, the split() function divides a text string into smaller pieces based on a specific separator (like a comma, space, or any character). The result is a list (array) of the individual parts.

The syntax for the split() function in Power Automate is:

split(text, separator)
  • text: The string of text you want to split.
  • separator: The character or string used to split the text. This can be a comma, space, or any other delimiter.

Suppose you have a string of employee names separated by commas (e.g., John Doe, Jane Smith, Robert Brown), and you want to split this string into an array.

1. Create an Instant Cloud flow and choose the trigger flow (i.e., manually trigger a flow). Then, an Initialize Variable action will be added to store the string of employee names.

  • Name: EmployeeNames
  • Type: String
  • Value: John Doe, Jane Smith, Robert Brown
Create an Array From a String Using split() Function in Power Automate

2. Add a Compose action to split the string into an array.

split(variables('EmployeeNames'), ',')
Power Automate Create an Array From a String Using split() Function

Now, click on save and run the flow manually. After the flow runs successfully, click the compose action to see the Output section.

Create an Array From a String Using split() Function using Power Automate

Conclusion

In this tutorial, I explained how to create an array from a string in Power Automate using three different functions: array(), createArray(), and split(). Each function allows you to manipulate a text string and convert it into an array, enabling you to process individual items, like email addresses or names, more efficiently within a flow. I showed how to use these functions in practical scenarios, such as sending notifications to users or splitting employee names from a string.

Also, we cover below examples:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…