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
| Action | What it does | Output variable |
|---|---|---|
| Append line to text | Adds a new line to existing text | Result |
| Get subtext | Takes characters from a start position | Subtext |
| Crop text | Takes text before, after or between flags | CroppedText, IsFlagFound |
| Pad text | Adds characters to reach a fixed length | PaddedText |
| Trim text | Removes spaces and line breaks at the start and end | TrimmedText |
| Reverse text | Reverses the order of characters | ReversedText |
| Change text case | Upper, lower, title or sentence case | TextWithNewCase |
| Create random text | Generates random characters, such as a password | RandomText |
| Split text | Splits text into a list | TextList |
| Join text | Joins a list into one text | JoinedText |
| Replace text | Replaces every match of a word or pattern | Replaced |
| Parse text | Finds the position of a word or pattern | Position, Match |
| Convert text to number / number to text | Changes the data type | TextAsNumber / FormattedNumber |
| Convert text to datetime / datetime to text | Reads or formats dates | TextAsDateTime / 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:

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

The %Result% variable holds both 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:


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:


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:


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:



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:


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


| Option | “power platform” becomes |
|---|---|
| Upper case | POWER PLATFORM |
| Lower case | power platform |
| Title case | Power Platform |
| Sentence case | Power 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:


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:


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/yyyyfor 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:
- Variables in Power Automate Desktop
- Get Substring from String in Power Automate Desktop
- Concatenate Strings Using Power Automate Desktop
- Update Data Table Items using Power Automate Desktop
- How to Get Values from Data Table using Power Automate Desktop?
- Retrieve Excel Column Values Into List Using Power Automate Desktop
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.

I have worked with Microsoft technologies for more than 18 years, including SharePoint, Microsoft 365 and the Power Platform (Power Apps, Power Automate and Power BI), at companies like HP, TCS and KPIT. I started EnjoySharePoint in 2011 to share the solutions I build in real projects with readers in the United States, Canada, the United Kingdom, Australia, New Zealand and beyond. Microsoft has recognized this work with the Microsoft MVP award 13 times since 2014.