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 Newline in Flo...
Power Automate
Answered

Replace Newline in Flow Expression

(4) ShareShare
ReportReport
Posted on by 111

I have a flow that is parsing a plain text email and creating an item in a SharePoint list.

 

Everything works great except for when a user enters data with a newline or carriage return (which I don't want in the SP list). I can not figure out how to replace a new line (\n) or any other non-printable character.

 

I have tried the obvious...

 

replace(body('Html_to_text'), '\n', '')

I have tried what others claim to be the only solution...

 

replace(body('Html_to_text'), '
', '')

As well as several other options (e.g.; character codes)...

 

replace(body('Html_to_text'), Char(13), '')

And nothing works (even when the run doesn't generate an error, the new lines are not replaced). I am able to replace printable characters without issue, it's just the non-printable characters.

 

So, am I missing something or is it impossible to do what I'm trying to do?

Categories:
I have the same question (0)
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @FlowNick,

     

    Thanks for posting.

    I will make some tests and share the results.

    Regards,

    Michael

  • Verified answer
    FlowNick Profile Picture
    111 on at

    Thanks Michael.

     

    Here's what I'm currently using as a workaround:

     

    uriComponentToString(replace(uriComponent(body('Html_to_text')), '%0A', ''))

    I figured, since I can replace printable characters, I'd just temporarily convert the string to all printable characters, replace them, then convert it back. It's hack-ish and inefficient but working.

     

    I look forward to seeing your results.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks FlowNick - workaround works perfectly!

  • shahidsaud Profile Picture
    5 on at

    Saver of the day. this works awesome.

  • Megasween Profile Picture
    32 on at

    I think I just found a different work around.  needed to replay new lines with <br> html tag.  I initalied a variable string.  In the string I hit enter so the only character in the string was a new line.  I then used the dynamic variable in the experssion.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello,

     

    I'm havin gsome trouble with the same. I'm trying to leverage the solution found but dont know what the "body('Html_to_text')" is referring to. Can someone explain that funciton? Thanks!

  • FlowNick Profile Picture
    111 on at

    Hi @Anonymous,

     

    body('Html_to_text')

    represents data converted through the Content Conversion connector (docs).

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the reply Nick! i got it figured out.

  • TitoValle Profile Picture
    3 on at

    It works!! You saved me a lot of time and I'm really thankful  Cat Happy

  • stephenJames Profile Picture
    286 on at

    @FlowNick wrote:

    Thanks Michael.

     

    Here's what I'm currently using as a workaround:

     

    uriComponentToString(replace(uriComponent(body('Html_to_text')), '%0A', ''))

    I figured, since I can replace printable characters, I'd just temporarily convert the string to all printable characters, replace them, then convert it back. It's hack-ish and inefficient but working.

     

    I look forward to seeing your results.


    I hate to Necro, so sorry in advance. 

     

    I am using a similar bit of code to remove line breaks and apostrophes.

    uriComponentToString(replace(replace(uriComponent(body('Html_to_text')), '%0A', ''), '%27',''))

    This works to put evrything on a single line and removes the characters i dont need. However i cannot seem to get my substrings to run as i keep getting the following message

    flowerror.PNG

     

    @FlowNick mentioned that he " temporarily convert the string to all printable characters, replace them, then convert it back." . Is there a step to convert it back that i am missing?

     

     

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!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 77 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 68

#3
Expiscornovus Profile Picture

Expiscornovus 56 Most Valuable Professional

Last 30 days Overall leaderboard