Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Escape an HTML string - Bun
[go: Go Back, main page]

Skip to main content
The Bun.escapeHTML() utility can be used to escape HTML characters in a string. The following replacements are made.
  • " becomes """
  • & becomes "&"
  • ' becomes "'"
  • < becomes "&lt;"
  • > becomes "&gt;"
This function is optimized for large input. Non-string types will be converted to a string before escaping.
Bun.escapeHTML("<script>alert('Hello World!')</script>");
// &lt;script&gt;alert(&#x27;Hello World!&#x27;)&lt;&#x2F;script&gt;

See Docs > API > Utils for more useful utilities.