HTML Entity Encoder & Decoder

Escape and unescape HTML entities — safely, in your browser.

Free HTML entity encoder and decoder. Escape characters like < > & " for safe HTML, or decode named and numeric entities back to text. Runs entirely in your browser — nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Which characters get escaped?

Encoding escapes the HTML-significant characters & < > " and the apostrophe, and optionally all non-ASCII characters as numeric entities. Decoding understands named entities and decimal or hexadecimal numeric entities.

HTML entity encoder & decoder

Escape text for safe placement inside HTML — &, <, >, " and the apostrophe become their entity equivalents — or decode named and numeric entities back into plain text. Escaping is the core defence against breaking your page layout or introducing cross-site scripting when you display user-supplied text.

Why escaping matters

When you insert raw user input into HTML without escaping, a value like <script>alert(1)</script> executes as markup rather than displaying as text. Even something as simple as a username containing " can close an attribute prematurely and corrupt the page. HTML escaping converts those dangerous characters into inert display sequences that the browser renders as text, never as code.

How it works

In encode mode the tool replaces each HTML-significant character with its entity:

  • &&amp; (must be done first to avoid double-encoding)
  • <&lt;
  • >&gt;
  • "&quot;
  • '&#39; (numeric form, safer than &apos; which is undefined in HTML 4)

An optional setting additionally converts every non-ASCII character (accents, symbols, emoji) into a decimal &#NNN; numeric entity, producing pure-ASCII output for maximum email client and legacy system compatibility.

In decode mode it reverses the process, resolving named entities, decimal numeric references (&#233;), and hexadecimal numeric references (&#xE9;) — done through a parser that never injects your input into the live DOM, so untrusted markup cannot execute even while being decoded.

When to use each mode

ScenarioMode
Displaying user-supplied text in HTMLEncode
Writing dynamic content into an HTML attributeEncode
Preparing text for an HTML email bodyEncode (with non-ASCII option)
Reading a template file that contains &amp; etc.Decode
Debugging double-encoded stringsDecode, then re-encode

Worked example

Encoding <a href="x">Tom & Jerry</a> gives:

&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

Notice & is encoded as &amp; before the other characters are replaced, preventing &lt; from being re-encoded to &amp;lt;.

Decoding &copy; 2026 &mdash; caf&#233; gives © 2026 — café.

Quick reference table

CharacterNamed entityNumeric
&&amp;&#38;
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&#39;&#x27;
©&copy;&#169;
®&reg;&#174;
&trade;&#8482;

Everything runs in your browser — nothing is uploaded. Pair it with the URL encoder for query strings.