In Power Automate, you can work with converting and formating strings using string functions() and some of the collection functions.
In this tutorial, I will discuss how to deal with Power Automate string() functions with a few examples that include the below topics:
- Concat () function
- Substring() function
- Length() function
- Trim() function
- Replace() function
- Chunk() function
- Startswith() function
- Endswith() function
- Tolower() function
- Toupper() function
- Lastindexof() function
- Indexof() function
- nthindexof() function
- Split() function
Power Automate String Functions
The Power Automate string function converts strings and string characters, formats strings, and more.
Power Automate text functions are a basic technique that is extensively used to format data better or convert it to other sources.
So let’s discuss one by one.
Power Automate concat function
This is one of the Power Automate string functions, where it allows the combination of one or more strings and returns the combined string.
Syntax: concat('text1', 'text2', ...)Example:
1. In Power Automate, select manually trigger flow. Take two text inputs as shown below:

2. After that, add the Compose flow action and provide the concat() expression to combine the strings:
concat(triggerBody()?['text'],triggerBody()?['text_1'])
3. Now save the flow. Click on Test -> Select Manually. In the Runflow window, provide details like First Name and Last Name -> Select Runflow.

4. The body outputs of the compose action display the combined string, as shown below.

This is how to combine multiple strings using Power Automate string operations.
Power Automate Substring
To work with strings in Power Automate, you can use the substring() function, which returns the characters or a substring from a string based on position starting from zero.
Syntax: substring('text', startIndex, length)Example:
1. Create Power Automate Instant cloud flow.
2. Next, select the Initialize variable action and set the variable as Name, Type as string, and provide Value.

3. After that, to get the substring from the provided string, enter the below given expression in the Compose Inputs section.
substring(variables('Name'),6)
Output:
The below image represents the substring from a string in a Power Automate flow.

Power Automate Length of String
To count characters in a string using Power Automate, there is one useful function named the length() function that calculates and counts the number of characters in a string and the number of items in an array collection.
Syntax: length('string')
length([<collection>])Example:
1. Here, you can initialize a string value that is required to determine its length. Provide a name for a variable, select the type as a string, and enter the value.

2. To calculate a string’s length, provide the length() expression in the Compose flow action of the Power Automate flow.
length(variables('Greetings'))
Output:
The Power Automate length() expression will return an integer number by counting characters in a string.

Power Automate Trim() Function
The Power Automate text functions include the trim() function, which helps remove spaces from the beginning and end of a string.
Syntax: trim('text')Example:
1. Inside the Power Automate Manual trigger flow, take the text input.

2. Add the Compose action and provide the trim() expression to eliminate the spaces.
trim(triggerBody()?['text'])
3. Then, save and run the flow. In the Run flow window, enter the string value with spaces. Click Runflow.

Output:
As you can see in the image below, it will return the updated string, eliminating leading and trailing spaces.

Power Automate Replace String
To do Power Automate string manipulation, like replacing characters from a string, one can use a case-sensitive replace() expression. This expression replaces a substring with a specified string and updates the resulting string.
Syntax: replace('text', 'oldText', 'newText')Example:
1. Take an Initialize variable flow action, provide name, type, and value as shown in the below figure:

2. Inside the Compose flow action, add the expression to replace the string characters.
replace(variables('Name'),'Lidia','Patti')
3. When the flow runs successfully, you can check that the string has been replaced with a specific string, as shown in the image below:

Power Automate Chunk() Function
The string functions in Power Automate, like the chunk() function, will divide the string into equal halves based on the provided length. If the string remains with extra special characters, the remaining characters will also be considered one chunk.
Syntax: chunk('String', <length>)Example:
Suppose I will take a word as Hello World! Now, I need to break this word into chunks of length 2.
1. In a Power Automate Manual trigger flow, take an Initialize variable. Provide Name, Type, and Value.

2. In the inputs section of the Compose flow action, provide a chunk() expression that will split the string into equal chunks.
chunk(variables('Greetings'),2)
Output:
The output will show the below result. Refer to the image!

Power Automate startswith
The Power Automate string function has a commonly used function known as the startswith() function. It will determine whether a provided string starts with a particular substring and return a boolean value of True or False.
It is not a case-sensitive function.
Syntax: startsWith('text', 'searchText')Example:
Suppose I will take a sentence like ‘Welcome! Explore and enjoy your time here. I wanted to check whether the string begins with a specific substring [Hello]. Then, the output will return as false.
1. After that, take an Initialize variable flow action to store the value of a given string during the flow.
- Name: Provide a name for the string variable.
- Type: Select the datatype of a string from the drop-down as String.
- Value: Take the value like “Welcome! Explore and enjoy your time here“.

2. In the Compose flow action, take startswith() expression in it.
startsWith(variables('Greetings'),'Hello!')
Output:
If the string starts with the search text value, then the return value will be true, else it will be false.

The other function that resembles the Power Automate startswith() function:
| Function | Description | Syntax |
| endswith function | It determines whether a text input string ends with a specific value or a given string. | endsWith(‘text’, ‘searchText’) |
Power Automate ToLower Function
In Power Automate format strings, the tolower() function converts all the characters of a string to lowercase letters.
If the string contains lowercase letters, the characters will remain unchanged, and the function will return the same lowercase characters without changing them.
Syntax: toLower('text')Example: Assume a string as JoHAnna LoreNZ. Now, the return output will be johnna lorenz.
1. Select an Initialize variable flow action to set the variable’s value. Set the details like Name, Type, and Value.

2. Then, add a Compose flow action, and, in the Inputs property, provide the expression for the tolower expression of Power Automate, which will convert the text string to lowercase.
toLower(variables('Name'))
Output:
The result will be displayed in the compose flow action. It will display the string with all the lowercase letters.

Power Automate has one more function that resembles the tolower() function, as is mentioned in the table below:
| Function | Description | Syntax |
| toUpper() function | It will t sets all the characters of a provided string to capital letters. For the upper case letters, it will remain unchanged. | toUpper([string]) |
Power Automate Lastindexof
To string manipulation in Power Automate, text functions have the lastindexof() function. This function returns the starting position of the last occurrence of a string in a given string. It will also take space as an index, which will begin from 0.
Syntax: lastindexOf(['text'],'Search text ')Example:
The lastIndexOf(‘Johanna lorenz’,’n’) function would give the output ‘12‘. In the text ‘Johanna lorenz’, this function identifies the final occurrence of the character ‘n’ index.
1. Select the initialize variable action and then set the variable name, type as a string, and the value.

2. Now, select Compose action. In the Input, add the below expression:
lastIndexOf(variables('Name'),'n')
Result:
Save and test the flow manually. Then, see the result in the compose output.
- The last occurrence of the character ‘n’ position is 12.

| Function | Description | Syntax |
| IndexOf() function | It will return the starting position or index value for a substring. The first character in the position of ‘0’ not starts with ‘1’. | indexOf([‘text’],’Search text ‘) |
| nthIndexOf() function | indexOf([‘text’],’ Search text ‘) | nthIndexOf(‘text’, ‘searchText’) |
Power Automate Split String
The Power Automate string expressions also have a split function: This function will split the string into substrings of an array separated by commas based on the provided delimiter.
Syntax: split('text', 'delimiter')Example:
The code below contains the Product Details. Now, I wanted to split the strings based on the delimiter ‘|.’ The output will return an array that contains substrings.
Product Id - |WED845|
Product Type -|Keyboard|
Billing Date - |03/04/2024|
Estimated Delivery - |5|
Delivery Date - |08/04/2024|1. Initialize a variable by providing Name, Type, and Value as shown in the below figure:

2. After that, click on the next step, then select the compose action, and in the Inputs section, Insert the below expression:
split(variables('Product Details'),'|')
Output:
You can check out the screenshot below, which will split the string into an array of substrings separated with commas based on the delimiter ‘|.’

Also, you may like:
- Power Automate Split String into Array
- Power Automate Get Items Filter Query
- Power Automate Read Excel File From SharePoint
- Power Automate Rename SharePoint File
- Power Automate Date Functions
- Power Automate Parse Email Body
Conclusion
I trust that this Power Automate tutorial guide has information on all string functions that will be useful for manipulating text. I have covered a few examples:
- Power Automate the length of the string
- Power Automate concatenate strings
- Substring Power Automate example
- Power Automate trim string, etc.,

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.
Thanks, Bijay! I found your tutorial to be quite helpful and will check out your other resources.