HTML Entity Encoder

Encode special characters (&, <, >, ", ') into HTML entities, or decode HTML entities back to plain text.

  • Free to use
  • Accurate results
  • No registration required
  • Works on all devices
Enter text and choose Encode or Decode to convert special characters to/from HTML entities like &amp; and &lt;.
Action

Your result

&lt;div class=&quot;test&quot;&gt;Tom &amp; Jerry&#39;s&lt;/div&gt;

Result

AI explanation

Formula

Replaces &, <, >, ", ' with their named HTML entities (&amp; &lt; &gt; &quot; &#39;)

Worked example

Encode a snippet with quotes, an apostrophe, and an ampersand

Worked example: Encode a snippet with quotes, an apostrophe, and an ampersand
FieldValue
Text<div class="test">Tom & Jerry's</div>
Actionencode
Result&lt;div class=&quot;test&quot;&gt;Tom &amp; Jerry&#39;s&lt;/div&gt;

Assumptions

  • Covers the 5 characters with dedicated predefined HTML/XML entities — not a full named-entity table (e.g. accented letters are left as-is on encode).
  • Decoding also supports numeric entities (&#65; and &#x41;), in addition to the 5 named ones.

Frequently asked questions

Why do I need to encode these characters for HTML?

Characters like < and > are structurally meaningful in HTML (they start/end tags) — if you display user-provided or dynamic text containing them without encoding, browsers may misinterpret it as markup, and it can enable cross-site scripting (XSS) attacks.

What is the difference between &amp; and &#38;?

Both represent the same character (&) — &amp; is the named entity, while &#38; is the numeric entity using the character's Unicode code point. Browsers treat them identically.

Does this handle emoji or accented characters?

This tool only encodes the 5 characters with dedicated HTML entities (&, <, >, ", ') — other Unicode characters (emoji, accented letters) pass through unchanged, since modern HTML documents are UTF-8 by default and don't require escaping them.

Related calculators

Report a calculation issue