HTML Entity Encoder / Decoder

Encode text to HTML entities or decode entities back to plain text.

Free HTML entity encoder and decoder. Convert special and non-ASCII characters to named or numeric HTML entities, or decode entities back to plain text, entirely in your browser. Useful for template and email debugging. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Which characters get encoded?

The five characters that are syntactically significant in HTML — ampersand, less-than, greater-than, double quote, and apostrophe — are always encoded as named entities. Optionally, every non-ASCII character is encoded as a numeric reference so the output is pure ASCII.

HTML entities are escape sequences that let you include reserved or non-ASCII characters in HTML without breaking the markup. For example, < renders as a literal less-than sign instead of starting a tag. This free tool converts text to entities and back, helping you debug templates, sanitise attribute values, or prepare characters for an HTML email.

When you need encoding

Encoding is necessary whenever you insert dynamic or user-supplied text into an HTML document. Without it:

  • A value containing <script> could execute as markup (XSS).
  • A value containing " inside a double-quoted attribute could close the attribute prematurely.
  • A value containing & could corrupt an adjacent entity sequence.

The pure-ASCII mode (encoding all non-ASCII characters as numeric references) adds a second guarantee: the output is safe regardless of the character encoding the server declares. This is particularly useful for HTML emails, where mail clients and gateways have historically been less reliable than browsers about character encoding.

How it works

When encoding, the tool walks your text one character at a time. The five HTML-significant characters — &, <, >, " and ' — are replaced with their named entities. If you enable the non-ASCII option, every character above code point 127 becomes a numeric reference &#NNN; derived from its Unicode code point, producing pure-ASCII output.

When decoding, the tool matches each &...; sequence and resolves:

  • Named entities (e.g. &copy;©, &mdash;)
  • Decimal numeric references like &#8364;
  • Hexadecimal numeric references like &#x20AC;

&amp; is resolved last to avoid double-decoding — so a literal &amp;lt; in your input becomes &lt; (the entity text), not < (the character).

Worked examples

Encoding user input for display in HTML:

Input: Tom & Jerry <classics>

Output: Tom &amp; Jerry &lt;classics&gt;

Encoding for an HTML attribute value:

Input: I said "hello" & waved

Output: I said &quot;hello&quot; &amp; waved

Decoding an entity-laden template string:

Input: &copy; 2026 &mdash; caf&#233; au lait

Output: © 2026 — café au lait

Quick entity reference

CharacterNamed entityDecimal
&&amp;&#38;
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&#39;&#39;
©&copy;&#169;
&euro;&#8364;
&mdash;&#8212;

All encoding and decoding runs entirely in your browser — nothing you enter is sent to a server or stored anywhere.