web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Replace formula not co...
Power Automate
Suggested Answer

Replace formula not converting \n newlines to tags from adaptive card payload

(0) ShareShare
ReportReport
Posted on by Microsoft Employee
Hi everyone,
 
I'm trying to replace newline characters in a string coming from an Adaptive Card payload submission, but my `replace()` formula doesn't seem to be doing anything.
---
My formula:
```
replace(replace(coalesce(body('Parse_additional_details_card_payload')?['audienceProfile'], ''), '\r\n', '<br>'), '\n', '<br>')
```
 
Example payload received from the card:
```json
{
  "body": {
    "action": "submitModify",
    "actionSubmitId": "Submit",
    "audienceProfile": "course\n\ndescription\n\n\ntest",
    "comments": "course\n\ndescription\n\n\ntest",
    "courseDescription": "course\n\ndescription\n\n\ntest"
  }
}
```
 
The `audienceProfile` value clearly contains `\n` characters (visible in the raw JSON), but after the formula runs, the output string still contains the literal newlines — the `<br>` tags are not being inserted.
What I've tried:
- Replacing `'\n'` (escaped)
- Replacing `'\r\n'` (for Windows-style line endings)
None of these have worked so far.
 
My question:
How do I correctly match and replace actual newline characters (coming from an Adaptive Card submission) inside a Power Automate expression? Is there a special way to represent a literal newline in the `replace()` function?
 
Any help is appreciated — thanks in advance!
Categories:
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    3,418 on at
     
    The issue is that '\n' in Power Automate expressions is treated as a literal two-character string backslash-n, not an actual newline character. So your replace never finds a match.

    Use decodeUriComponent('%0A') to represent a real newline character instead:

    replace(body('Parse_additional_details_card_payload')?['audienceProfile'], decodeUriComponent('%0A'), '<br>')

    For \r\n use decodeUriComponent('%0D%0A'). Since Adaptive Cards typically only send \n, the single %0A version should do the job.
     
    Vishnu WR
     
    Please âœ… Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like â™¥
  • Suggested answer
    chiaraalina Profile Picture
    2,059 Super User 2026 Season 1 on at
    Hi
     
    Is this the output you are trying to achieve: course<br><br>description<br><br><br>test?
     
    Please try this
     
    replace(
      replace(
        coalesce(body('Parse_additional_details_card_payload')?['audienceProfile'], ''),
        decodeUriComponent('%0D%0A'),
        '<br>'
      ),
      decodeUriComponent('%0A'),
      '<br>'
    )
     
    Let me know if it worked!
  • Suggested answer
    Nanit Khanna Profile Picture
    68 on at

    Hi @IA-09020654-0,

    The issue is that Power Automate is handling actual newline characters, not the escaped string \n.

    Try using decodeUriComponent() to represent real line breaks:

    replace (
        coalesce(body('Parse_additional_details_card_payload')? ['audienceProfile'], ''),
        decodeUriComponent('%0A'),
        '<br>'
    )
    

    If your payload contains Windows-style line endings, use:

    replace (
        coalesce(body('Parse_additional_details_card_payload')? ['audienceProfile'], ''),
        decodeUriComponent('%0D%0A'),
        '<br>'
    )
    

    Why this works:
    • '\n' is treated as plain text in expressions
    • Adaptive Card submissions contain actual newline characters
    • decodeUriComponent('%0A') correctly represents a real line feed character

    This is the standard workaround commonly used in Power Automate for newline replacement.
     


     

    Please âœ… Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item.

    If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like!

  • Vish WR Profile Picture
    3,418 on at
     
    Wanted to check if you are able to resolve your problem? Let me know if you need any clarification 
     
     
    When replying, please don't forget to mention my userid so that it will be notified 
     
    Vishnu WR
     
    Please âœ… Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like â™¥

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 632

#2
Haque Profile Picture

Haque 458

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard