Skip to content
Calculator Tools
Developer Tools

HTML Encoder

Escape HTML special characters so text displays literally instead of being parsed as markup.

Enter values

Results update as you type.

Result

Escaped HTML

<script>alert("hi")</script> & more

Escaping is what stops user text being treated as markup — the single most important defence against cross-site scripting.

Characters escaped
7
Original length
35
Escaped length
61

About the HTML Encoder

Escape HTML special characters so text displays literally instead of being parsed as markup.

Also known as: html escape, encode html entities, escape html characters, xss escape.

How to use this calculator

  1. Enter text to escape.
  2. The result updates instantly as you type — press Calculate (or Enter) at any time.
  3. Review the breakdown shown under the main result.
  4. Use Copy result or Share to save the answer or send a link with your inputs.

Formula

& < > " and ' become their named or numeric entities

Worked example

Using the values pre-filled in the calculator above:

  • Text to escape: <script>alert("hi")</script> & more

the calculator returns:

  • Escaped HTML: &lt;script&gt;alert(&quot;hi&quot;)&lt;/script&gt; &amp; more
  • Characters escaped: 7
  • Original length: 35
  • Escaped length: 61