Power Automate Desktop Text Actions (With Examples)

Almost every desktop flow I build ends up cleaning text: an order number buried in an email subject, a customer name with extra spaces from a web form, a CSV line that needs splitting. Power Automate Desktop has a group of Text actions for this, and once you know a handful of them, you rarely need to write a script.

In this tutorial, I’ll walk through the text actions I use most, with an example for each, and point out the small gotchas, like zero-based positions and leftover spaces, that cause most mistakes.

Quick answer: Find the text actions under Text in the Actions pane. Use Get subtext to take characters by position, Crop text to take text before or after a word, Split text to turn text into a list, Replace text to swap words, Trim text to remove spaces at the ends, and Change text case for upper, lower or title case. Positions start at 0, and each action saves its result in a variable, such as %Subtext%.

The text actions at a glance

ActionWhat it doesOutput variable
Append line to textAdds a new line to existing textResult
Get subtextTakes characters from a start positionSubtext
Crop textTakes text before, after or between flagsCroppedText, IsFlagFound
Pad textAdds characters to reach a fixed lengthPaddedText
Trim textRemoves spaces and line breaks at the start and endTrimmedText
Reverse textReverses the order of charactersReversedText
Change text caseUpper, lower, title or sentence caseTextWithNewCase
Create random textGenerates random characters, such as a passwordRandomText
Split textSplits text into a listTextList
Join textJoins a list into one textJoinedText
Replace textReplaces every match of a word or patternReplaced
Parse textFinds the position of a word or patternPosition, Match
Convert text to number / number to textChanges the data typeTextAsNumber / FormattedNumber
Convert text to datetime / datetime to textReads or formats datesTextAsDateTime / FormattedDateTime

There are a few more, such as Escape text for regular expression, Recognize entities in text and Create HTML content, which I cover briefly at the end.

Append line to text

This adds a line to the end of existing text, which is handy for building a message or a log. I start with a variable, %Product%, set with Set variable:

Set variable action storing product ID and name text in the Product variable

Then Append line to text adds the stock line. Original text is the variable, and Line to append is the new text:

Append line to text action adding a stock update line to the Product variable

The %Result% variable holds both lines:

Result variable with the product details and the stock update on two lines

Get subtext

Get subtext takes part of a text by position. Set Start index to Character position and enter where to start, then set Length to End of text or Number of chars. Positions start at 0, so in “Power Automate Desktop Flows”, the D of Desktop is at position 15:

Get subtext action with a character position and End of text length
Subtext variable containing Desktop Flows

If you start one character early, you get a leading space. And if the start or length goes past the end of the text, the action fails with “Start index or length are out of range.”

Crop text

Crop text is often easier than counting positions: it takes the text before, after or between words you choose, called flags. To get “Power Automate”, choose Get text before the specified flag and use Desktop as the End flag:

Crop text action getting the text before the flag Desktop
CroppedText variable containing Power Automate

Two details. The result keeps the space before “Desktop”, so use ” Desktop” (with a space) as the flag, or trim the result. And the action also returns %IsFlagFound%; check it with an If action before you use the text, in case the flag wasn’t there.

Pad text

Pad text adds characters to the left or right until the text reaches a length, which is useful for fixed-width files or product codes. Here, the code X9Zj32 is padded on the left with * to 10 characters:

Pad text action padding the product code on the left with asterisks to 10 characters
PaddedText variable containing the padded product code

For leading zeros on a number, pad with 0, for example 42 becomes 0000000042.

Trim text

Trim text removes spaces, tabs and line breaks from the start, the end or both. This variable has a stray space and line break around the text:

Set variable with product text that has extra whitespace and a line break
Trim text action removing whitespace from the beginning and end
TrimmedText variable with the whitespace removed from both ends

Trim only touches the ends, so the line break between the two lines stays. To remove spaces or line breaks inside the text, use Replace text with a regular expression, such as \s+ replaced with a single space.

Reverse text

Reverse text flips the order of the characters, so “Power Automate” becomes “etamotuA rewoP”. It’s mostly useful for tricks like finding the last occurrence of a character:

Reverse text action with Power Automate as the text to reverse
ReversedText variable containing the reversed text

Change text case

Change text case converts text to Upper case (the default), Lower case, Title case or Sentence case:

Change text case action converting power platform to upper case
TextWithNewCase variable containing POWER PLATFORM
Option“power platform” becomes
Upper casePOWER PLATFORM
Lower casepower platform
Title casePower Platform
Sentence casePower platform

Lower case is my go-to before comparing text, so “Yes”, “YES” and “yes” all match.

Create random text

Create random text generates random characters, which can be useful for temporary passwords or test data. Choose whether to include uppercase letters, lowercase letters, digits and symbols, and set a minimum and maximum length (6 and 10 by default). With different values, the length is random between them; set both to the same number for a fixed length:

Create random text action with uppercase, lowercase, digits and symbols and a length range
RandomText variable containing a generated password

Split text

Split text turns text into a list. Choose a Standard delimiter (space, tab or new line) or a Custom one. Here, a comma splits a list of Power Platform products:

Split text action splitting a list of products with a comma as a custom delimiter
TextList variable with each product as a separate item

Look closely at the result: every item after the first starts with a space. Use “, ” (comma and space) as the delimiter, or turn on Is regular expression and use ,\s*, which matches a comma followed by any spaces. In a regular expression, \d matches any digit, so you could split “A1B2C3” on digits the same way. (Power Virtual Agents in this example is now called Microsoft Copilot Studio.)

Join text

Join text does the reverse: it combines a list into one text, with a delimiter you choose. Joining the list above with “, ” gives “Power Automate, Power BI, Power Apps, Power Virtual Agents” again. It’s the easy way to turn a list of email addresses into one line separated by semicolons.

Replace text

Replace text finds every match of a word and replaces it. For example, to update an email address in a template, set:

  • Text to parse: sales@contoso.com
  • Text to find: sales
  • Replace with: orders

The %Replaced% variable then holds orders@contoso.com. Turn on Ignore case to match regardless of capitals; with it off, the match is case-sensitive. Turn on Use regular expressions for find and replace for patterns, and Activate escape sequences if the replacement contains codes like \t for a tab.

Parse text

Parse text finds where a word or pattern appears. It returns %Position% (starting at 0) and, with a regular expression, the matched text in %Match%. If nothing is found, Position is -1, which is a convenient check. For example, with ORD-\d{5} as a regular expression, it pulls “ORD-10482” out of an email subject.

Convert text, numbers and dates

  • Convert text to number turns “1250.50” into a number you can calculate with. It fails on text that isn’t a number, so trim it first.
  • Convert number to text formats a number with decimal places and a thousands separator: 1234.5 becomes 1,234.50, and you can add a $ in front.
  • Convert text to datetime reads a date, including custom formats such as yyyyMMdd.
  • Convert datetime to text formats a date for people, for example with the custom format MM/dd/yyyy for 09/27/2026.

Other text actions

Escape text for regular expression makes user input safe to use in a pattern. Recognize entities in text finds dates, amounts, phone numbers, email addresses and URLs in free text. Create HTML content builds formatted content for the Outlook and email actions. For extracting text in other ways, see how to get a substring in Power Automate Desktop.

These Power Automate Desktop tutorials go further:

Frequently Asked Questions

How do I get part of a text in Power Automate Desktop?

Use Get subtext with a start position (counting from 0) and a length, or Crop text to take the text before or after a word. Microsoft lists every text action in its Text actions reference.

How do I split text into a list in Power Automate Desktop?

Use Split text with a standard or custom delimiter. Use “, ” instead of “,” so the items don’t start with spaces.

How do I remove spaces in Power Automate Desktop?

Trim text removes spaces at the start and end. For spaces inside the text, use Replace text with a regular expression.

Is Replace text case-sensitive?

Yes, unless you turn on Ignore case.

Why does Get subtext fail?

The start position or length goes past the end of the text. Positions start at 0, so check the length first.