Split a String Into an Array in Power Automate

While working with Power Automate for one of my clients, there are many situations where you might need to split a string into an array. For example, you might receive a list of values separated by commas, spaces, or even line breaks. In such cases, you can use the split() function to break the string into individual parts and process them easily in your flow.

In this tutorial, I will explain how to use the split() function in Power Automate with various types of delimiters, including commas, spaces, and newlines. I will also show how to handle more advanced scenarios such as splitting using multiple delimiters, extracting text between two characters, and looping through the split array.

Let’s explore how to split a string into an array in Power Automate step by step with examples.

Split String Using the split() Function in Power Automate

In Power Automate, the split() function is used to break a string into an array based on a specific delimiter. This is helpful when you have a long string that contains multiple values separated by a character like a comma, space, colon, or any other symbol.

Syntax of the split() function:

split(text, delimiter)
  • text: This is the full string you want to split.
  • delimiter: This is the character or symbol where you want to split the string.

For example, let’s say you have the following string:

"Red-Blue-Green"

To split it using the hyphen (-) as the delimiter, use the expression:

split('Red-Blue-Green', '-')

This will return the array:

[
  "Red",
  "Blue",
  "Green"
]
Split String Using the split() Function in Power Automate

You can use this output directly in actions like Apply to each, or you can retrieve individual items from the array using their index.

Split String by Comma Separator using Power Automate

One of the most common scenarios in Power Automate is working with comma-separated values (CSV). For example, you might receive a list of email addresses, product names, or locations in a single string separated by commas. Using the split() function, you can easily break these values into an array and use them in our flow.

Now follow the steps below:

Suppose you receive the following string, which I added in the compose action:

"California,Texas,Florida,New York,Illinois"
split comma separated string in power automate

To split this string into individual state names, use the following expression:

split(outputs('Compose'),',')
Split comma delimited (array) string variable to list separated in Power Autoamte

After the flow runs, you can see that this will return the array:

[
  "California",
  "Texas",
  "Florida",
  "New York",
  "Illinois"
]
Split String by Comma Separator using Power Automate

You can now loop through this array using the Apply to each action in Power Automate and perform actions like filtering data, sending emails, or creating SharePoint items for each state.

Tip:

If the items have extra spaces (“California, Texas”), use the trim() function to remove them: trim(items(‘Apply_to_each’))

Check out: Create a Multi-Agent in Copilot Studio

Split String by Space in Power Automate

Sometimes, you may receive a string that contains words separated by spaces. An everyday use case in Power Automate is splitting a full name into its first and last names. You can easily do this using the split() function with a space (‘ ‘) as the delimiter.

Let’s say your Power Automate flow receives a string like this:

"John Smith"

To split this into first and last name, follow these steps:

  1. Create an Instant cloud flow (with a manual trigger).
  2. Add a “Initialize variable” action:
    • Name: FullName
    • Type: String
    • Value: John Smith
How to use Power Automate to split a string into an array
  1. Add another “Compose” action and use the split() Expression:
split(variables('FullName'), ' ')
power automate split string into array

This will return an array:

[
"John",
"Smith"
]
  1. To store the first and last names separately:
    • Add a “Initialize variable” action:
      • Name: FirstName
      • Type: String
      • Value: outputs(‘Compose’)?[0]
    • Add a “Initialize variable” action:
      • Name: LastName
      • Type: String
      • Value: outputs(‘Compose’)?[1]
Split String by Space in Power Automate

After that, click Save and then Run it manually. Once it runs successfully, open the Run History and check the values of the variables.

Power Automate Split String by Space

This technique is especially useful when you’re processing user data from a Microsoft Form, SharePoint list, or a custom app that collects full names in a single field.

Power Automate Split String by New Line

In some scenarios, especially when collecting data from Microsoft Forms or emails, you may receive multiple lines of text in a single field. Each line might represent a separate item, such as product names, city names, or notes. In Power Automate, you can split this string into an array using a new line as the delimiter.

Suppose a user submits the following multiline string in a form:

New York
Los Angeles
Chicago
Houston
Phoenix

You want to split this into individual city names.

Follow the steps below:

  1. Create an Instant cloud flow (with a manual trigger).
  2. Add a “Initialize variable” action:
    • Name: cityName
    • Type: String
    • Value: Above value
  3. Add another “Initialize variable” action:
    • Name: lineBreak
    • Type: String
    • Value: leaveblank
Get the next line after in an array with Power Automate

Read more: Add Copilot Studio Knowledge Files Using Power Automate

  1. Add a Compose action to split the string using a new line delimiter:
split(variables('cityName'),variables('lineBreak'))
How to add new line ('n') to a string in Power Automate

Once you set up the actions, click Save and then Run the flow. After it runs, open the Run History and check the output of the Compose

power automate split string into array by new line

You can also get the same thing using the following expression:

split(variables('cityName'),decodeUriComponent('%0A'))

Check out: Create Autonomous Agents in Copilot Studio

Split String Using Multiple Delimiters Using Power Automate

In some cases, you may receive a string that uses more than one type of separator, for example, a mix of commas, semicolons, and pipes. Power Automate’s split() function only supports one delimiter at a time, but with a bit of help from the replace() function, you can standardize the string before splitting it.

Let’s say your input string looks like this:

Texas;California|Florida,New York

This string uses three different delimiters: semicolon (;), pipe (|), and comma (,). To split it, you’ll first replace all the delimiters with a common one, like a comma, and then split the string.

Follow the steps below:

  1. Trigger the flow manually or through a form.
  2. Add an “Initialize variable” action:
    • Name: StateList
    • Type: String
    • Value:
Texas;California|Florida,New York
  1. Add a Compose action to clean the string by replacing the other delimiters:
replace(replace(replace(variables('StateList'), ';', ','), '|', ','), ' ', '')
power automate split

This replaces ‘;’ and ‘|’ with ‘,’ and removes any unwanted spaces.

  1. Add another “Compose” action to split the cleaned string:
split(outputs('Compose'), ',')
power automate split array

Output:

Split String Using Multiple Delimiters Using Power Automate

Split String and Loop Through Array in Power Automate

Once you split a string into an array in Power Automate, I want to loop through each item and perform actions, such as sending an email.

The best way to do this is by using the ‘Apply to each’ control option.

Suppose you have the following string of email addresses:

LidiaH@*****.onmicrosoft.com,PattiF@*****.onmicrosoft.com,MiriamG@*****.onmicrosoft.com

You want to split this string and send an email to each person individually.

  1. Create an Instant cloud flow. Add an “Initialize variable” action:
    • Name: EmailList
    • Type: String
    • Value:
LidiaH@*****.onmicrosoft.com,PattiF@*****.onmicrosoft.com,MiriamG@*****.onmicrosoft.com
  1. Add a “Compose” action to split the string:
split(variables('EmailList'), ',')
power automate split text
  1. Add an “Apply to each” action:
    • Select the output of the Compose action as the array to loop through.
power automate array split items

Read: Create an Agent Flow Using Designer in Copilot Studio

  1. Inside the loop, add a “Send an email (V2)” action:
    • To: trim(items(‘Apply_to_each’))
    • Subject: Hello from Power Automate
    • Body:
This is a test email sent using Power Automate.
power automate split text via regex

Click Save, then Run the flow. After it finishes, check the Run History to verify that Power Automate sent separate emails to each address on the list.

power automate split string

Looping through a split string is one of the best ways to handle dynamic data in Power Automate. Whether you’re processing email addresses, product IDs, or form entries, combining split() with Apply to each gives you the flexibility to handle them one by one.

As you can see, Power Automate makes it incredibly easy to split a string into an array using the split() function. Whether you’re dealing with commas, spaces, new lines, or even multiple types of delimiters, you can use your flows to handle dynamic and structured data in a few simple steps.

You can split a string using any delimiter, hyphen, pipe, semicolon, or even custom symbols by just modifying the delimiter value in the split() expression.

You may also like:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

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