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
import _
_
from 'radashi'
import _
_
.
function escapeHTML(input: string): string

Escape HTML characters in a string.

@seehttps://radashi.js.org/reference/string/escapeHTML

@example

escapeHTML('<div>Hello, world!</div>')
// => '&lt;div&gt;Hello, world!&lt;/div&gt;'

@version12.6.0

escapeHTML
('<div>Hello, world!</div>')
// => '&lt;div&gt;Hello, world!&lt;/div&gt;'