HTML entity encoder

Escape and unescape HTML entities, with a searchable reference table.

Entity reference

& & &
< &lt; &#60;
> &gt; &#62;
" &quot; &#34;
' &apos; &#39;
&nbsp; &#32;
© &copy; &#169;
® &reg; &#174;
™ &trade; &#8482;
€ &euro; &#8364;
£ &pound; &#163;
¥ &yen; &#165;
¢ &cent; &#162;
§ &sect; &#167;
&para; &#182;
† &dagger; &#8224;
‡ &Dagger; &#8225;
• &bull; &#8226;
… &hellip; &#8230;
– &ndash; &#8211;
— &mdash; &#8212;
‘ &lsquo; &#8216;
’ &rsquo; &#8217;
“ &ldquo; &#8220;
” &rdquo; &#8221;
« &laquo; &#171;
» &raquo; &#187;
° &deg; &#176;
± &plusmn; &#177;
× &times; &#215;
÷ &divide; &#247;
¼ &frac14; &#188;
½ &frac12; &#189;
¾ &frac34; &#190;
≈ &asymp; &#8776;
≠ &ne; &#8800;
≤ &le; &#8804;
≥ &ge; &#8805;
← &larr; &#8592;
→ &rarr; &#8594;
↑ &uarr; &#8593;
↓ &darr; &#8595;
↔ &harr; &#8596;
α &alpha; &#945;
β &beta; &#946;
π &pi; &#960;
Σ &sigma; &#931;
Ω &Omega; &#937;
∞ &infin; &#8734;
√ &radic; &#8730;
∑ &sum; &#8721;

How it works

HTML entities let you write characters that would otherwise be interpreted as markup, or that are hard to type. &lt; renders as a literal less-than sign instead of opening a tag.

The five that matter

&, <, >, " and '. Escaping these before inserting user content into a page is the foundational defence against cross-site scripting. Everything else is convenience.

Escaping is context-dependent

HTML-escaping is correct inside element content and attribute values. It is not sufficient inside a <script> block, a URL, or a CSS value — each needs its own escaping. This is why hand-rolled escaping keeps producing vulnerabilities, and why templating engines that escape by context are worth using.

Named, decimal and hex

&copy;, &#169; and &#x00A9; all produce ©. HTML5 defines over two thousand named entities; numeric references work for any code point and need no lookup table.

You usually do not need entities for accents

With a UTF-8 charset declared — which every modern page has — you can write café directly. Entities for accented characters are a holdover from the days of ambiguous encodings.