Quick access

HTML Encoder

Encode and decode HTML special characters for safe embedding.

Input
Output
Encode: chars Decode: chars

Quick Examples

Character Reference

& → &
< → &lt;
> → &gt;
" → &quot;
' → &apos;
& → &amp;
→ &nbsp;
© → &copy;
® → &reg;
™ → &trade;
<3 → &lt;3
¢ → &cent;

About the HTML Encoder

The HTML encoder replaces characters that have a special meaning in HTML, such as < and &, with safe codes like &lt; and &amp;, so text shows up as written instead of being read as markup.

How to use it

  1. 1 Paste text or HTML into the input.
  2. 2 Choose Encode or Decode.
  3. 3 Copy the safe output.

Frequently asked questions

Which characters need escaping in HTML?

At minimum: & (&amp;), < (&lt;), > (&gt;), double quotes (&quot;), and single quotes (&#39;) inside attribute values.

Does HTML encoding prevent XSS?

Escaping user input before putting it into HTML is a key defence against cross-site scripting, but you also need the right escaping for JavaScript, URLs, and CSS contexts.

What is the difference between this and the HTML Entity tool?

This tool escapes only the characters that must be escaped. The HTML Entity tool can also turn every non-ASCII character into a named or numeric entity.

', style: '', quotes: 'He said "Hello" and \'Hi\'', ampersand: 'Tom & Jerry are friends' }; this.input = examples[type] || ''; this.encode(); }, clearAll() { this.input = ''; this.output = ''; }, copyOutput() { navigator.clipboard.writeText(this.output); } }; }