Skip to the content

HTML Encode

Escape the characters that HTML treats as markup, so text shows up literally on a page.

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

Example

In
<a href="/">Tom & Jerry</a>
Out
&lt;a href=&quot;/&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

Good to know

  • Five characters are replaced: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &#39;. That is enough to place text safely in HTML content and in quoted attributes.
  • Accented letters and emoji are left alone. On a UTF-8 page, which is practically every page today, they need no escaping.
  • Escaping is what stops text typed by a visitor from being run as code. Do it at the moment the text is put into the page, not when it is stored.

How HTML entity works, with a worked example, is explained on the HTML Entity Encoder/Decoder page.

See all 15