HTML Entity Encoder & Decoder - Escape & Unescape HTML Characters

Escape HTML syntax characters safely for displaying code snippets or user text inside web pages, and decode named, decimal, or hex HTML entities back into readable text inside your browser.

HTML Entity Encoder & Decoder

How to use the HTML Entity Encoder & Decoder

  1. 1Pick Encode to Entities or Decode Entities using the two direction buttons at the top left.
  2. 2When encoding, keep Encode all non-ASCII characters (numeric) unchecked to escape only the five core HTML characters (&, <, >, ", '), or check it to convert extended Unicode symbols to numeric &#code; entities too.
  3. 3Paste your raw HTML snippet or escaped entity text into the left textarea to view the live output on the right.
  4. 4Click Copy to save the converted result, Swap Input & Output to check round-tripping, or Clear to reset.

What the HTML Entity Encoder & Decoder does

The tool runs pure string-level escaping and unescaping directly inside your browser without executing or mutating DOM tags:

  • Encodes ampersand (&), less-than (<), greater-than (>), double quote ("), and single quote (') into &amp;, &lt;, &gt;, &quot;, and &#39;.
  • Optionally converts every character with a Unicode code point above 127 into a decimal numeric HTML entity such as &#169; when Encode all non-ASCII characters is checked.
  • Decodes decimal entities (&#dec;), hexadecimal entities (&#xhex;), and 13 common named entities (&amp;, &lt;, &gt;, &quot;, &#39;, &apos;, &nbsp;, &copy;, &reg;, &trade;, &mdash;, &ndash;, &hellip;) back into plain text.
  • Includes Clear, Swap Input & Output, and Copy buttons so you can verify safe round-trip escaping locally.

Example

Sample HTML snippet (Encode mode, reserved characters only)
<div class="card">5 > 3 & "Free"</div>
Escaped HTML entity output
&lt;div class=&quot;card&quot;&gt;5 &gt; 3 &amp; &quot;Free&quot;&lt;/div&gt;

Clicking Swap Input & Output switches to Decode Entities and converts that escaped string right back into the literal HTML snippet.

Frequently asked questions

Which characters must be escaped in HTML?

At minimum, escape ampersand (& to &amp;), less-than (< to &lt;), greater-than (> to &gt;), double quote (" to &quot; inside attributes), and single quote (' to &#39; in single-quoted attributes).

What is the difference between named and numeric HTML entities?

Named entities use memorable labels like &lt; or &copy;, while numeric entities use the character Unicode code point in decimal (&#60;) or hexadecimal (&#x3C;). Both render the exact same symbol in browsers.

Why does escaping special characters help prevent broken HTML?

If literal < or & characters appear unescaped inside content or attributes, the browser HTML parser can mistake them for opening tags or broken attribute boundaries, scrambling layout or breaking templates.

Can this tool decode both decimal and hexadecimal numeric entities?

Yes. Decode mode converts decimal entities like &#169;, hex entities like &#xA9;, and common named entities back into their plain characters.

Related tools

View All Tools