I am using a LWC lightning-input-rich-text that is populated from a custom field value when my LWC loads. This component is used to Send an email where body of email will be the text( value ) in this input rich text. When I send the email I get additional paragraph for each line break present in the text. Could not find this behavior anywhere in documentation, this one says that <p> tag is added for text enclosed in <div> or <p> tags , but my rich text does not have any of this, and this behavior is observed wherever there is a line break.

Is this a bug? Is there any workaround for this? I tried replacing all <p> and </p> tags with blanks but this will also remove the required

tags that were explicitly added in rich text originally.

Resulting Email:

enter image description here

  • I could resolve this issue by replacing <p><br></p> with blank in my code. But waiting for any better or standard solution for this.
    – Sarang
    Commented Jul 2, 2021 at 9:51
  • Raised a case with SF for this.
    – Sarang
    Commented Jul 10, 2021 at 7:06

1 Answer 1


As per case resolution from Salesforce, this is expected behaviour. Here is the gist of SF explanation:

The WYSIWYG nature of how our rich text editor displays content only applies to the Lightning Experience. If the output of our rich text editors is viewed in non-Lightning contexts (such as in an e-mail), there will be visual inconsistencies. We have created a user story to update the rich text edit doc with the above content, soon the doc will also be updated with this content.

So the most feasible workaround at this point of time is replacing <p><br></p> with blank.

Ex : body.replaceAll('<p><br></p>',''); //'body' is the value in input rich text

  • Hi Sarang, can you please add your apex code? The value that I got from LWC does not have additional <br> but the emails that were sent have them.
    – User2529
    Commented Mar 29, 2023 at 9:52
  • I don't have the code with me now, but there is nothing special in the code to mention as such. Did you debug and print/observed the value? If you don't get the tags in 'value' , and get them in actual email, can you try replacing that in the email body string from apex?
    – Sarang
    Commented Mar 30, 2023 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .