Are you trying to replace newlines in a string with <br> tags using Power Automate? Unfortunately, Power Automate does not allow you to process new line characters using the replace function, which is a non-printable character.
When trying to replace the ‘\n’, which represents a new line, the replace function will consider it as a ‘\n’ string, but it won’t process as a new line.
I will help you with this!
In this tutorial, I will explain how to replace line breaks from a string with <br> tags using Power Automate. Here, I will describe two different ways:
- By storing New Line in a variable
- By getting a New Line from the expression
Replace New Line with <br> tags in Power Automate using a Variable
To illustrate this example, I will use a text string that contains newlines. Here, I will use the Email body content that needs to be sent in the email, including newlines. You can see the string placed below.
Hi All,
Just a quick reminder that we have a holiday coming up on [15-08-2025] for Independence Day.
Happy holidays!
Warm regards,
Alex WilberNow, I wanted to replace the new lines present in the above string with <br> tags, so that the output can be sent in an email.
Let’s see how to do it by using a new line variable in the flow:
- Create an Instant cloud flow in Power Automate by selecting ‘Manually trigger a flow’ trigger action. If you’re a beginner, consider checking out Power Automate’s Instant Cloud Flow.
- Now, add an ‘Initialize variable‘ action and provide the below-mentioned parameters.
- Name: Enter a name for a variable.
- Type: Choose the data type as ‘String’.
- Value: Provide your string value. I will set the value as below.

- Then, add another Initialize variable that will store the new line in a variable. Set the name, type as a string, and Value as a new line (Press enter once inside the value field).

- Then, add a ‘Compose‘ action to provide the replace expression as mentioned below.
@{replace(variables('VarEmailBody'),variables('VarLinebreak'),'<br>')}
- After that, add ‘ Send an email(V2)‘ action: Configure To, Subject, and Body parameters. In the Body parameter, insert the outputs of the compose action in the code view.
In the email body, HTML format is present, where the Power Automate will consider <br> tags and break the line of the email body.

At this step, save and manually run the flow. After the flow runs successfully, you can see that the new lines were replaced by the <br> tags.
Have a look at the reference image placed below:


Replace New Line with <br> Tags using Power Automate Flow Expression
Here, I will explain another approach to replace a new line with < br> tags using an expression in Power Automate.
In the previous example, we have stored a new line in a variable. In this example, we will get the new line from the ‘decodeUriComponent(‘Uri value’) expression.
decodeUriComponent('%0A') - Returns new line characterLet’s recreate the previous example by using decodeUriComponent(‘%0A’) in the replace expression.
I will use the exact string:
Hi All,
Just a quick reminder that we have a holiday coming up on [15-08-2025] for Independence Day.
Happy holidays!
Warm regards,
Alex WilberDo follow the steps below:
- Create a Power Automate Instant cloud flow, triggered by clicking on a button.
- Take an ‘Initialized variable‘ action with the string value that is provided in the code above.

- Then, add a ‘Compose’ action that will provide the replace expression. In the Inputs parameter, insert the expression given in the code.
- decodeUriComponent(‘%0A’)-> Decodes %0A value that will give the new line character.
replace(variables('VarEmailBody'),decodeUriComponent('%0A'),'<br>')
- To see the output, you can add a ‘Send an email(V2)’ action and set the parameters such as To, Subject, and specify the Body in code view with outputs of the compose action.

Save and test the flow.
Output: Replaced New lines with <br>


That’s how you can replace new lines with <br> tags in a string using Power Automate.
You can use any of the methods mentioned above to replace the new line with <br> tags using Power Automate.
If you have any suggestions for me, please leave your comments in the section below.
Read Other Power Automate Tutorials:
- Power Automate Replace Text in File
- Replace a File in SharePoint using Power Automate
- Replace Spaces with Underscores in String Power Automate
- Replace Double Quote with Single Quote 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.