Skip to main content
CalcChef

HTML Entity Encoder

Encode text to HTML entities (& < > " ') or decode any of the 2,231 named references in the HTML standard and numeric ones such as é. How it works

Use the HTML Entity Encoder

Up to 500,000 characters. The output updates as you type.

Escaping these characters is correct for text and quoted attributes. It does not make input safe inside a script, a style block, a URL or an unquoted attribute.

About the HTML Entity Encoder

To show a character as text in HTML, write & as &amp;, < as &lt;, > as &gt;, " as &quot; and ' as &#39;. This HTML entity encoder does that, and can also write other non-ASCII characters as numeric (&#233;) or named (&eacute;) references. Decode reads the 2,231 named references of the HTML standard and every numeric form.

One line in each encode style

Encode styleTom & Jerry's café: 5 € becomes
MinimalTom &amp; Jerry&#39;s café: 5 €
All non-ASCII as numericTom &amp; Jerry&#39;s caf&#233;: 5 &#8364;
Names where availableTom &amp; Jerry&#39;s caf&eacute;: 5 &euro;

Common characters as HTML entities

CharacterNames styleNumeric style
&&amp;&amp;
<&lt;&lt;
>&gt;&gt;
"&quot;&quot;
'&#39;&#39;
©&copy;&#169;
®&reg;&#174;
é&eacute;&#233;
£&pound;&#163;
€&euro;&#8364;
♥&hearts;&#9829;
😀&#128512;&#128512;

The first five are escaped in every style. A character with no name in the standard, such as 😀, gets a numeric reference in the names style too.

How Decode reads unusual references

InputDecodedWhy
&Alpha; &alpha;Α αNames are case-sensitive
&Copy;&Copy;Not a name in the standard, so left as typed
&copy©A legacy name, valid without the semicolon
&notit;¬it;The longest legacy name at the start, &not, is read
&#128;€128 to 159 are read as windows-1252 characters
&#0;�Zero becomes U+FFFD
&amp;lt;&lt;One pass: the result is not decoded again

Frequently asked questions

Which characters must be escaped in HTML?
In text and in quoted attribute values: & < > " and '. The minimal style writes them as &amp; &lt; &gt; &quot; and &#39; and leaves everything else, such as é and €, as typed, which is fine in a UTF-8 page.
Does encoding HTML entities prevent XSS?
Only in some places. Escaping these five characters is right for text and quoted attributes. It does not make input safe inside a script, a style block, a URL or an unquoted attribute, as the note under the tool says; those need escaping for that context.
Are HTML entity names case-sensitive?
Yes. &Alpha; is Α and &alpha; is α. &Copy; is not a name in the standard, so Decode leaves it as typed, while &copy; is ©.
How many named HTML entities are there?
The HTML standard’s table has 2,231 entries: 2,125 names written with a semicolon, and 106 of them listed a second time without it, such as &copy and &amp. Decode reads all of them; the table is loaded the first time you decode or pick the names style.
Why does &#128; decode to the euro sign?
The HTML parser does not read 128 to 159 as control characters but through the windows-1252 table, where 128 is €. &#0;, surrogates and values above 10FFFF in hex decode to U+FFFD (�). When encoding, the tool leaves characters U+0080 to U+009F as they are, so they survive a round trip.

Related Tools

View all tools