ToolMelt

HTML Entities Cheat Sheet

HTML entities cheat sheet: special character codes for &, <, >, quotes, dashes, curly quotes, arrows, math and currency symbols — named, decimal and hex.

This guide pairs with a free tool:

Open the HTML Entities Encoder / Decoder

HTML reserves a handful of characters for its own syntax, so writing them literally can break a page or open a security hole. This cheat sheet lists the HTML entities and special character codes you actually need: the five escape characters first, then a typography table, then the rules for when each form is required.

Why escaping matters

The characters < > & and " are control characters in HTML markup. A bare < starts a tag, so writing "a < b" in your source makes the browser hunt for a tag named "b". Worse, inserting user text into a page without escaping lets an attacker inject real markup: a comment containing <script>alert(1)</script> runs as code. Converting those characters to HTML escape characters — &lt;, &gt;, &amp;, &quot; — turns executable markup back into inert text.

The 5 must-know entities

CharacterNamedDecimalHexNotes
& (ampersand)&amp;&#38;&#x26;Escape first — every other entity begins with it
< (less than)&lt;&#60;&#x3C;Mandatory in text: it would otherwise open a tag
> (greater than)&gt;&#62;&#x3E;Technically optional in text, but always escape it for symmetry
" (double quote)&quot;&#34;&#x22;Required inside double-quoted attribute values
' (apostrophe)&apos;&#39;&#x27;Named form is HTML5; use &#39; for older parsers

Typography and symbols cheat sheet

Dashes, quotes and spaces

CharacterNamedDecimalHex
— em dash&mdash;&#8212;&#x2014;
– en dash&ndash;&#8211;&#x2013;
‘ ’ single curly quotes&lsquo; &rsquo;&#8216; &#8217;&#x2018; &#x2019;
“ ” double curly quotes&ldquo; &rdquo;&#8220; &#8221;&#x201C; &#x201D;
… ellipsis&hellip;&#8230;&#x2026;
non-breaking space&nbsp;&#160;&#xA0;
• bullet&bull;&#8226;&#x2022;

A non-breaking space keeps two words on the same line (write 10&nbsp;km so "10" never dangles alone) and is not collapsed like a run of normal spaces.

Arrows and math

CharacterNamedDecimalHex
← ↑ → ↓ arrows&larr; &uarr; &rarr; &darr;&#8592;&#8595;&#x2190;&#x2193;
× multiplication&times;&#215;&#xD7;
÷ division&divide;&#247;&#xF7;
− minus sign&minus;&#8722;&#x2212;
± plus-minus&plusmn;&#177;&#xB1;
≠ ≤ ≥ not equal, less/greater or equal&ne; &le; &ge;&#8800; &#8804; &#8805;&#x2260; &#x2264; &#x2265;
∞ infinity&infin;&#8734;&#x221E;

Legal and currency

CharacterNamedDecimalHex
© copyright&copy;&#169;&#xA9;
® registered&reg;&#174;&#xAE;
™ trademark&trade;&#8482;&#x2122;
€ euro&euro;&#8364;&#x20AC;
£ pound sterling&pound;&#163;&#xA3;
¥ yen&yen;&#165;&#xA5;
¢ cent&cent;&#162;&#xA2;

Named vs numeric entities

Named entities are readable (&mdash; says what it is), but HTML defines only a fixed set of them — just over two thousand names. Numeric references cover every Unicode code point, so characters with no name — emoji, rare symbols, most non-Latin letters — exist only in decimal or hex form: a snowman is &#9731; or &#x2603;, nothing else. All three forms decode identically in every modern browser, and the hex letters are case-insensitive. One real caveat: &apos; was missing from HTML 4 (it came from XML) and only became standard with HTML5, so &#39; remains the safest apostrophe for very old parsers. In practice, pages served as UTF-8 can include almost any character literally; entities are mandatory only for the markup-significant five.

Where entities are required

Attribute values

Inside a double-quoted attribute, a literal double quote ends the value early: <a title="Say &quot;hi&quot;"> is correct, while an unescaped inner quote truncates the title and leaves the dangling text to be parsed as new attributes. The ampersand must be escaped here too, because attribute values are entity-decoded before use.

Script and style pitfalls

<script> and <style> are raw-text elements: the parser does not decode entities inside them. Writing &lt; in a script gives the JavaScript engine the four characters "&", "l", "t", ";" — not a less-than sign — so never entity-encode code; instead avoid literal closing tags like </script> inside strings. The reverse trap is assuming entities protect user input placed inside a script block: they do not, because no decoding happens there.

Common mistakes

Try it: paste any messy string — markup snippets, curly quotes, symbols — into the HTML Entities Encoder / Decoder and convert it to named or numeric entities, or decode an escaped string back to readable text. Everything runs in your browser; nothing is uploaded.

More guides