HTML Entities Encoder and Decoder - Named, Decimal and Hex

Turn text into HTML entities, or decode entities back into text.

About this tool

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.

How it works

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.

Worked examples

Escape a tag for display

The text <a href="x">Tom & Jerry's</a> with the five specials encoded becomes &lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&#39;s&lt;/a&gt;. Paste that into a page and a browser shows the original text instead of treating it as a link.

Non-ASCII characters

With all non-ASCII characters encoded, café © 2026 becomes caf&eacute; &copy; 2026. The euro sign can be written &euro;, &#8364; or &#x20AC;, because 8364 in decimal is 20AC in hexadecimal. Both numbers are U+20AC.

Decode back to text

&lt;p&gt;caf&eacute;&lt;/p&gt; decodes to <p>café</p>, and &#65;&#x42;&#67; decodes to ABC. The text &amp;lt; decodes to &lt;, one step only, which is what a browser would show.

A character with no name

U+1F600 has no named reference. It is written &#128512; (decimal) or &#x1F600; (hexadecimal) as one reference. It is not split into two surrogate halves, which would not be valid.

Common HTML entities, with code points from the WHATWG HTML Standard

EntityCharacterCode pointUse
&amp;&U+0026Ampersand, must be escaped
&lt;<U+003CLess-than sign, must be escaped
&gt;>U+003EGreater-than sign
&quot;"U+0022Double quotation mark
&apos;'U+0027Apostrophe (HTML 5 and XML; &#39; works everywhere)
&nbsp;(no-break space)U+00A0No-break space
&copy;©U+00A9Copyright sign
&reg;®U+00AERegistered sign
&trade;™U+2122Trade mark sign
&euro;€U+20ACEuro sign
&pound;£U+00A3Pound sign
&yen;¥U+00A5Yen sign
&cent;¢U+00A2Cent sign
&sect;§U+00A7Section sign
&para;U+00B6Paragraph sign
&deg;°U+00B0Degree sign
&plusmn;±U+00B1Plus-minus sign
&times;×U+00D7Multiplication sign
&divide;÷U+00F7Division sign
&frac12;½U+00BDOne half
&frac14;¼U+00BCOne quarter
&frac34;¾U+00BEThree quarters
&middot;·U+00B7Middle dot
&bull;•U+2022Bullet
&hellip;…U+2026Horizontal ellipsis
&ndash;(en dash)U+2013En dash
&mdash;(em dash)U+2014Em dash
&lsquo;‘U+2018Left single quotation mark
&rsquo;’U+2019Right single quotation mark, also the typographic apostrophe
&ldquo;“U+201CLeft double quotation mark
&rdquo;”U+201DRight double quotation mark
&laquo;«U+00ABLeft double angle quotation mark
&raquo;»U+00BBRight double angle quotation mark
&larr;←U+2190Leftwards arrow
&rarr;→U+2192Rightwards arrow
&uarr;↑U+2191Upwards arrow
&darr;↓U+2193Downwards arrow
&hearts;♥U+2665Black heart suit
&check;✓U+2713Check mark
&infin;∞U+221ELemniscate (infinity symbol)
&ne;≠U+2260Not equal to
&le;≤U+2264Less-than or equal to
&ge;≥U+2265Greater-than or equal to
&shy;(soft hyphen)U+00ADSoft hyphen, invisible unless a line breaks there
&eacute;éU+00E9Latin small letter e with acute

Frequently asked questions

What is the difference between &amp; and &#38;?

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.

Do I need to encode non-ASCII characters in HTML?

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.

Is &apos; valid?

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.

Does decoding run scripts or load images in the text?

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.

Why does &copy 2026 decode without a semicolon?

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.

How do I write a non-breaking space?

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.

Are entity names case sensitive?

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.

Updated Oct 13, 2026