I am currently working within a Lightning Component where I have returned the contents of a rich text field from a knowledge article to a <div> section of the page. Instead of the browser rendering the rich text contents as HTML, it is being rendered only as text, which also displays all of the HTML markup on the page.

Since I am working in a Lightning component I do not seem to have access to functions such as {!HTMLENCODE}, but I'm not sure if that is what I would be looking for anyway. I not sure if there is some way I can convert the rich text content to HTML characters either in the Apex controller or on the client side before displaying it to the page?

Thank you everyone. I look forward to any information you can provide.

I have attached a screenshot for reference.enter image description here


To output pre-formatted HTML, use aura:unescapedHTML.

You can pass in values from a controller, such as:

<aura:unescapedHtml value="{!v.note.body}"/>
  • Thanks so much. I'm not how I overlooked this component. It worked just as described! Jun 29 '15 at 14:39

Since aura:unescapedHtml introduces the possibility of security vulnerabilities in your code, better solution would be:

<lightning:formattedRichText value="{!v.yourHTMLContent}"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.