I was recently working with the Replace() function in Power Automate, which allows us to replace characters, substrings, or strings in arrays, multiple objects in JSON format, and more.
In this article, I will explain how to replace special characters from a string in Power Automate with the following examples.
- Replace a Single Special Character from a String in Power Automate
- Replace Multiple Special Characters in a String with Power Automate
Replace a Single Special Character from a String using Power Automate
To illustrate this example, I will manually take a text string with a special character. Below you can see the string separated with a comma:
Power Apps, Power Automate, Power BI, Power PagesNow, I wanted to replace the comma (,) with (|) in the string mentioned above.
You can do this by using the replace() function in Power Automate.
Check out the steps below to know how to do it:
- On Power Automate, create an Instant cloud flow. If you are new to Power Automate, check out how to create a Power Automate Instant cloud flow.
- Following the trigger, add an ‘Initialize variable‘ that stores the text string with special characters. Provide a name for the variable, Type as String, and Value as a string with special characters.

- Next, add a ‘Compose‘ action to replace the special character(,) in a string with another special character(|). Set the Inputs parameter with the below expression.
replace(variables('VarPowerPlatform'),',','|')
- Now, click on the Save icon to save the flow. Then, run it manually. When the flow executes successfully, you can see the output as displayed below.
Output:

This is how to replace special characters in Power Automate.
Check out Power Automate Replace Text in File
Replace Multiple Special Characters in a String using Power Automate
For this example, let me take a text string that consists of multiple special characters.
The string I will use: Automate Workflows * Power Automate & analyze data | Power BI—collaborate using # Power Apps @ scale! PowerPlatform.
Here, I wanted to replace all the special characters [*,&,|,—,#,@,! ] in the above string with Colon [:].
Steps to follow to achieve this:
- You can create a Power Automate manual trigger flow that can be triggered by a single button.
- To replace multiple special characters, we first need to create an array containing all the special characters. Add an Initialize variable action. Set the parameters mentioned below.
- Name: Here, I named the variable as ‘VarSpecialCharacters‘.
- Type: Select ‘Array‘ data type.
- Value: Insert the expression below.
Value: createArray('.','@','ß','²','³','µ','`','´','°','^','=','(',')','&','$','§', '~','#','%','*',':','<','>','?','/','|','!',''',''','+','-','%',':','—','__','___')
- Next, I will declare another ‘Initialize variable‘ to store the text string containing special characters. Set the name, type, and value parameters.

- Then, take one more ‘Initialize variable’ action that stores an empty value that is used to hold values within the Apply to each action. Provide the name, set type as string, and value as an empty value.

- Next, add an ‘Apply to each loop’ action by taking an array of special characters in Select an output from the previous steps.

- Inside the loop, add a ‘Set variable‘ action to replace all the special characters with one character and declare it in an empty string variable.
- Name: Select an empty string variable from the previous steps.
- Value: Insert the expression below.
replace(variables('VarTextString'),item(),',')
- Next, take one more ‘Set variable‘ action to replace all the repeating characters. Set the parameters below:
- Name: Here, take a text string variable with multiple special characters.
- Value: Provide the expression placed below.
replace(variables('VarReplaceCharacters'),',',':')
- To display the output, add a ‘Compose’ action outside of the loop. In the Inputs parameter, take a [Text string variable – variables(‘VarTextString’)].

Save and execute the flow manually by clicking on the Runflow button.
Output:

This is how you can replace special characters in a string using Power Automate.
I hope you now learn how to replace special characters in a string using Power Automate.
Found this article helpful? Leave your feedback or suggestions in the comments section!
Other Power Automate Tutorials you may like:
- Replace String in JSON Power Automate
- Replace Value in an Array in Power Automate
- Replace Apostrophe in String Power Automate
- Replace Commas With New Lines in Power Automate
- How to Replace Multiple Strings using Power Automate?

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.