HTML entity encoder and decoder
Common HTML entities
Click a box to copy its named code. The second line is the numeric code for the same character.
HTML entities explained
An HTML entity is a short code that stands for a character: < for <, & for &, é for é. Browsers turn them back into characters when they display a page. This tool converts in both directions right in your browser — paste text to make it safe for HTML, or paste encoded HTML to read it.
How to use it
- 1 Choose Encode to turn characters into entities, or Decode to turn entities back into characters.
- 2 Paste your text. When encoding, choose whether only the five special characters or everything outside ASCII is converted, and in which format.
- 3 Copy the result. A warning appears if the input already looks encoded, or if entities remain after decoding.
Which characters must be encoded
Only five characters have a special meaning in HTML: & starts an entity, < and > open and close tags, and " and ' end attribute values. Encode these whenever you put user text into a page or an attribute — it is also the basic defence against HTML injection. Everything else, including é, ü, ç or Chinese characters, can be written as is when the page is saved and served as UTF-8 (<meta charset="utf-8">). Encoding all non-ASCII characters is only needed for systems that are not UTF-8 safe, such as some old email templates or databases.
Named or numeric?
Named entities such as é or © are easy to read but exist only for a fixed list of characters: HTML5 knows more than 2,000 names, while older software only knows the 252 from HTML 4. Numeric references work for every character — é (decimal) and é (hexadecimal) are the same é — so they are the safest choice. With “Named where possible” the tool uses an HTML 4 name when there is one and hexadecimal otherwise. ' is not part of HTML 4, so the apostrophe is always written as '.
The double encoding trap
If text that already contains < is encoded again, its & becomes & and you get &lt;. The browser then shows the literal text < instead of a < sign — the familiar &amp; and &quot; on badly built pages. It usually happens when a template escapes text that was already escaped before it was stored. Decode once and look at the result: if entities are still there, the tool offers to decode again.
Emoji and other characters above U+FFFF
JavaScript stores emoji and other characters above U+FFFF as two 16-bit halves, a so-called surrogate pair. Tools that encode one half at a time turn the grinning face into �� — two invalid references that browsers display as two replacement characters (�). This tool reads whole code points, so the same emoji becomes 😀 (decimal 😀). Emoji built from several code points, such as flags, skin tones or family groups, are encoded as a sequence of references and come back intact when decoded.