# HTML Entities Encoder and Decoder - Named, Decimal and Hex

Page: https://hirantha.me/tools/html-entities-encoder
Part of: Hirantha Sandaruwan Lakshan free tools (https://hirantha.me/tools)
Updated: 2026-10-13

Encode text to HTML entities as names, decimal or hex and decode them back, with all 2,125 named references of the HTML standard and a table of the common ones.

This is a free tool that runs in the browser: open the page to use it. File tools process files on the visitor's own device; files are never uploaded or stored. No account, sign-up, payment or watermark.

Turn text into HTML entities, or decode entities back into text. Encode only the five characters that matter in HTML (& < > " '), every non-ASCII character, or everything, as a name such as &eacute; where the HTML standard has one and as a decimal or hexadecimal number where it does not. The decoder knows all 2,125 named references in the standard plus decimal and hexadecimal numbers, and it never hands the text to a browser parser, so nothing in it can run.

What an entity is. A character reference starts with an ampersand and ends with a semicolon, and stands for one or two characters. It can be a name (&copy;), a decimal number (&#169;) or a hexadecimal number (&#xA9;). All three mean the same character, U+00A9. You need them to show a literal < or & in HTML, and they let you write characters that your keyboard or your file encoding cannot.

Which characters to escape. In text between tags, & and < must be escaped, and > is escaped by habit. Inside a double-quoted attribute value the double quote must be escaped too, and the apostrophe inside a single-quoted one. OWASP's cross-site scripting guidance lists these same five characters. The apostrophe is written &#39; by default, because &apos; is not defined in HTML 4. Tick the box if you want &apos;, which HTML 5 and XML accept.

Choosing names. When a character has several names, the encoder prefers its HTML 4 name, so &hellip; rather than &mldr; and &nbsp; rather than &NonBreakingSpace;, and otherwise takes the shortest. A character with no name gets a number. Outside the five specials, names are only used for non-ASCII characters. The everything option writes letters and digits as numbers too, which is rarely useful beyond tests and obfuscation, and it adds no security.

How decoding works. The decoder follows the HTML standard's tokenizer rules for text. Names are case sensitive, so &Eacute; is a capital E with an acute and &eacute; is a small one. A reference with no semicolon still decodes if it is a number, or one of the 106 legacy names such as &copy and &amp, using the longest legacy name that fits. So &notit; gives the not sign followed by it;, which is the standard's own example. Numbers follow the standard too: 0, surrogates and values above U+10FFFF become U+FFFD, and most of 128 to 159 map to the Windows-1252 characters, so &#128; is the euro sign. Tick Strict to require the semicolon.

The table and its limits. The decoder uses the full list of the HTML standard, taken from its entities.json on 2026-10-13: 2,125 names that end in a semicolon and 106 legacy names that work without one, 2,231 entries in all. The standard says the list is static and will not change. Decoding happens once, so &amp;lt; becomes &lt; and not <. Names that are not in the list are left as typed and shown in a warning. A few names stand for two characters, such as &NotEqualTilde;. They decode correctly but are never chosen when encoding, because the encoder works one character at a time.

Common HTML entities, with code points from the WHATWG HTML Standard:
| Entity | Character | Code point | Use |
| --- | --- | --- | --- |
| &amp; | & | U+0026 | Ampersand, must be escaped |
| &lt; | < | U+003C | Less-than sign, must be escaped |
| &gt; | > | U+003E | Greater-than sign |
| &quot; | " | U+0022 | Double quotation mark |
| &apos; | ' | U+0027 | Apostrophe (HTML 5 and XML; &#39; works everywhere) |
| &nbsp; | (no-break space) | U+00A0 | No-break space |
| &copy; | © | U+00A9 | Copyright sign |
| &reg; | ® | U+00AE | Registered sign |
| &trade; | ™ | U+2122 | Trade mark sign |
| &euro; | € | U+20AC | Euro sign |
| &pound; | £ | U+00A3 | Pound sign |
| &yen; | ¥ | U+00A5 | Yen sign |
| &cent; | ¢ | U+00A2 | Cent sign |
| &sect; | § | U+00A7 | Section sign |
| &para; | ¶ | U+00B6 | Paragraph sign |
| &deg; | ° | U+00B0 | Degree sign |
| &plusmn; | ± | U+00B1 | Plus-minus sign |
| &times; | × | U+00D7 | Multiplication sign |
| &divide; | ÷ | U+00F7 | Division sign |
| &frac12; | ½ | U+00BD | One half |
| &frac14; | ¼ | U+00BC | One quarter |
| &frac34; | ¾ | U+00BE | Three quarters |
| &middot; | · | U+00B7 | Middle dot |
| &bull; | • | U+2022 | Bullet |
| &hellip; | … | U+2026 | Horizontal ellipsis |
| &ndash; | (en dash) | U+2013 | En dash |
| &mdash; | (em dash) | U+2014 | Em dash |
| &lsquo; | ‘ | U+2018 | Left single quotation mark |
| &rsquo; | ’ | U+2019 | Right single quotation mark, also the typographic apostrophe |
| &ldquo; | “ | U+201C | Left double quotation mark |
| &rdquo; | ” | U+201D | Right double quotation mark |
| &laquo; | « | U+00AB | Left double angle quotation mark |
| &raquo; | » | U+00BB | Right double angle quotation mark |
| &larr; | ← | U+2190 | Leftwards arrow |
| &rarr; | → | U+2192 | Rightwards arrow |
| &uarr; | ↑ | U+2191 | Upwards arrow |
| &darr; | ↓ | U+2193 | Downwards arrow |
| &hearts; | ♥ | U+2665 | Black heart suit |
| &check; | ✓ | U+2713 | Check mark |
| &infin; | ∞ | U+221E | Lemniscate (infinity symbol) |
| &ne; | ≠ | U+2260 | Not equal to |
| &le; | ≤ | U+2264 | Less-than or equal to |
| &ge; | ≥ | U+2265 | Greater-than or equal to |
| &shy; | (soft hyphen) | U+00AD | Soft hyphen, invisible unless a line breaks there |
| &eacute; | é | U+00E9 | Latin small letter e with acute |

Q: What is the difference between &amp; and &#38;?
A: None. Both are the ampersand, U+0026: the first by name and the second by its decimal number. &#x26; is the same character in hexadecimal. A browser treats all three identically.

Q: Do I need to encode non-ASCII characters in HTML?
A: Not if the page is served as UTF-8, which is the default today: the characters can be written directly. Entities help when the file encoding is unknown, when you want the source to stay plain ASCII, or when a character is hard to type.

Q: Is &apos; valid?
A: It is valid in HTML 5 and XML, but HTML 4 did not define it, and very old browsers ignore it. &#39; works everywhere, so the tool uses that unless you tick the box.

Q: Does decoding run scripts or load images in the text?
A: No. The decoder is plain string code. It never gives the text to a browser parser, never sets innerHTML and never creates elements, so a string such as <img src=x onerror=alert(1)> is only ever text.

Q: Why does &copy 2026 decode without a semicolon?
A: Browsers accept 106 legacy names, such as copy, amp and lt, without the closing semicolon, for compatibility with very old pages. The HTML standard calls it a parse error but still decodes it. Tick Strict to require the semicolon.

Q: How do I write a non-breaking space?
A: Use &nbsp; or &#160;. It looks like a space, but a line will not break there, and several in a row are not collapsed into one the way ordinary spaces are in HTML.

Q: Are entity names case sensitive?
A: Yes. &Eacute; is E with an acute accent and &eacute; is e with an acute accent. Some names exist in both cases with a different meaning, so copy the case exactly.

Sources: Named character references, WHATWG HTML Standard (https://html.spec.whatwg.org/multipage/named-characters.html); Tokenization: numeric character reference end state, WHATWG HTML Standard (https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state); Character entity references in HTML 4 (252 entities, no apos), W3C (https://www.w3.org/TR/html4/sgml/entities.html); Cross Site Scripting Prevention Cheat Sheet, OWASP (https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html)

Related tools:

- [URL encode & decode](https://hirantha.me/tools/url-encoder.md): Percent-encode text for a URL, or decode it back.
- [Base64 encode & decode](https://hirantha.me/tools/base64.md): Convert text to Base64 and back, right in your browser.
- [Markdown previewer](https://hirantha.me/tools/markdown-previewer.md): Type Markdown and see it rendered live: headings, lists, tables, task lists, links and code. A small safe parser, copy as HTML, nothing uploaded.
- [JSON formatter & validator](https://hirantha.me/tools/json-formatter.md): Pretty-print, minify, and validate JSON with clear error locations.
