Power Automate Split: How to Split Text and Arrays
In this article
In Power Automate, use the split() expression to divide a text string wherever a separator appears: split(text, delimiter). For example, split('red,blue,green', ',') returns an array containing red, blue, and green. Add the expression in a flow action’s Expression editor, then use the resulting array directly or select an item by its zero-based index.
What split does in a flow
split() is a Power Automate Workflow Definition Language function. It takes two arguments: the string to divide and the delimiter that marks each division. The output is an array, not another text string. This distinction matters because later actions can loop over the array, count its items, or retrieve a particular item.
The delimiter can be a comma, a space, a line break, a hyphen, or another string. Splitting on a comma separates comma-delimited values; splitting on a space separates words. The function matches the delimiter as provided, so choosing the right separator is important. Splitting Jordan Lee on a space creates two elements, while splitting it on a comma does not divide the name.
Split does not automatically trim spaces, validate data, or remove empty items. Those details depend on the incoming text and may require additional expressions or actions.
How to add split to a flow
- Open the flow in Power Automate and add the action where you need the split result. For a quick demonstration, add a Compose action.
- Click the action’s input, then choose the Expression tab or option in the dynamic content pane.
- Enter an expression such as
split(triggerBody()?['Subject'], ','), replacing the example field with the property or dynamic content in your flow. - Choose Add or Update to insert the expression, then save and test the flow with representative input.
In the expression editor, enter the expression itself. In a Compose input, you can also build an expression using the editor’s expression option. Do not put an expression in quotation marks as if it were plain text; doing so can make the flow output the characters rather than evaluate the function. The exact labels and pane layout can vary between the modern designer and other designer versions.
For fixed sample data, use split('red,blue,green', ','). For a real flow, use a trigger or action field instead of the quoted sample. The safe-navigation operator in triggerBody()?['Subject'] helps avoid an error if that property is missing, but it does not turn a non-string value into a string automatically.
Use the array: loop, count, or select an item
Once split returns an array, choose what the flow should do with it. For example, to process each value, add an Apply to each action and select the split output as its input. Inside the loop, the current item represents one element. This is useful for handling a list of email addresses, tags, file names, or other values stored in a delimited field.
To retrieve one item, use an array index. Indexes start at zero, so index 0 is the first item, 1 is the second, and so on. Given the sample split expression, split('red,blue,green', ',')[1] returns blue. An index that does not exist can cause a failure, so check the array length or use a condition when the input may contain fewer items than expected.
To count the parts, wrap the result in length(), as in length(split('red,blue,green', ',')), which returns 3. This can support a condition, such as checking that a record contains the expected number of fields before using indexes. The count is the number of elements produced, including empty elements created by adjacent or trailing delimiters.
Practical examples and delimiter choices
For a text field containing North|West|Retail, split on the pipe character with split(triggerBody()?['RegionText'], '|'). The result is an array with three values. This pattern is common when a source system puts several values into one text field rather than providing a structured array.
For a line-separated list, the delimiter must match the line-break characters in the input. A common expression uses decodeUriComponent('%0A') for a line feed: split(outputs('Compose'), decodeUriComponent('%0A')). Some sources use Windows-style carriage-return and line-feed pairs, so inspect the actual input if the result is not separating as expected. You may need to normalize line endings or use the delimiter used by that source.
For a date-like string such as 2026-11-22, splitting on - produces year, month, and day text. This is only text separation; it does not validate the date or convert the pieces into a date value. If the source provides structured date data, using its date property is generally safer than parsing a formatted string.
Common problems and ways to avoid them
- Wrong delimiter: The output may contain one item if the delimiter does not appear exactly in the input. Check for commas versus semicolons, spaces, or different line endings.
- Whitespace remains: Splitting
red, blueon a comma yields a second value with a leading space. Use a trimming step or expression for each item if clean values are required. - Unexpected empty values: Text such as
red,,bluecontains an empty section between the two commas. A trailing delimiter can also create an empty final item. Decide whether to keep, reject, or filter these values. - Null or missing input: A missing property is not the same as an empty string. Check that the source field exists and contains text before splitting; use a condition or an appropriate default where the flow’s logic permits it.
- Index out of range: Do not assume every record has the same number of parts. Check the array length before requesting an item at a fixed index.
- Expression treated as text: Add it through the Expression editor rather than typing it as ordinary text in a field.
Also be cautious about using split to parse complex formats. A comma-separated field may contain quoted commas, and a file path or sentence may contain the character you chose as a separator. For structured data such as JSON, use the relevant parsing action or schema instead of relying on a simple delimiter.
Split compared with related options
Use split() when one string has a known separator and you need its parts as an array. Use Apply to each after splitting when every part needs similar processing. Use Parse JSON when the source is JSON and you need typed properties or nested arrays; splitting JSON text on commas or braces is unreliable because those characters can appear within values.
If you need to combine array items into one string later, the related join() function works in the opposite direction: it joins an array with a chosen delimiter. If the data source already supplies an array, there is no need to split it again. Prefer the structured value when available, because it avoids separator and formatting problems.
Frequently Asked Questions
Does split return an array or a string?
It returns an array of strings. Use an array-aware action such as Apply to each, an index, or a function such as length() to work with the result.
Are split indexes zero-based?
Yes. The first item is at index 0, the second at index 1, and the third at index 2.
How do I split text on a line break?
Use the line-break sequence present in the source. A line feed can be represented with decodeUriComponent('%0A'); some inputs use carriage return plus line feed, so check the actual data if it does not split as expected.
Can split use more than one delimiter at once?split() takes one delimiter per call. If the input uses multiple separators, normalize them first or apply additional transformations and splitting steps appropriate to the data.
Why does my result contain blank items or spaces?
Adjacent or trailing delimiters can create empty elements, and spaces next to a delimiter remain part of the value. Inspect the input and trim or filter elements if the flow should discard them.