Skip to content

escapeHTML

Escape HTML characters in a string

147 bytes
since v12.6.0

Usage

Replaces all occurrences of the following characters with their corresponding HTML entities:

  • & with &
  • < with &lt;
  • > with &gt;
  • " with &quot;
  • ' with &#39;
import * as _ from 'radashi'
_.escapeHTML('<div>Hello, world!</div>')
// => '&lt;div&gt;Hello, world!&lt;/div&gt;'