What Is HTML Entity Encoding?
HTML entity encoding converts special characters into safe representations that browsers display literally instead of interpreting as markup. Characters like < > & and quotes have special meaning in HTML — if included raw in content, they can break your page layout or create XSS (cross-site scripting) security vulnerabilities.
Essential Entities
& → & (ampersand). < → < (less than). > → > (greater than). " → double quote. ' → single quote. → non-breaking space. These six entities are the most critical for safe HTML content.
How to Use This HTML Entity Encoder
- Paste your text or HTML — Enter the content containing special characters that need encoding.
- Select the encoding mode — Named (reserved characters and about 40 common symbols as names), Numeric or Hex (non-ASCII characters as numeric references), or All → Numeric / All → Hex (every character, ASCII included).
- View the encoded output — See the HTML entities generated — both named entities (like &) and numeric entities (like &).
- Copy and use — Paste the encoded text into your HTML where special characters need to be displayed literally.
Worked example: encoder output checked in a browser
Until October 12, 2026 the Named mode turned every space into , the Numeric and Hex modes split emoji into two broken references and the decoder knew 40 of HTML's 2,231 named references. All three are fixed. We then ran the tool's own functions in Chromium: decoding matched Python's html.unescape (the WHATWG list) on 12 of 12 test strings, and 5 strings × 5 modes all decoded back to the original text.
| Mode | Input | Output | Result |
|---|---|---|---|
| Named (default) | 5 < 6 & café 😀 | 5 < 6 & café 😀 | spaces stay spaces; only characters with a name are replaced |
| Numeric / Hex | 😀 | 😀 / 😀 | one reference per character, renders as 😀 |
| Numeric | 👨👩👧 | 👨‍👩‍👧 | the joined emoji keeps its zero-width joiners |
| Decode | 😀 | 😀 | correct above U+FFFF |
| Decode | ’ ♥ & ¬ | ’ ♥ & ¬ | all named references, including legacy forms without a semicolon |
| Decode | | U+00A0 | a real non-breaking space |
| Decode | </textarea><script>… | the same text back | decoded as text; nothing runs |
- Decoding uses the browser's own parser. The text is parsed the way a page would parse it inside a <textarea>, so every reference HTML defines is recognised, invalid ones (�, �) become U+FFFD as the standard says, and markup in the input is never executed.
- Encoding works by character, not by UTF-16 unit. Emoji and other characters above U+FFFF become a single numeric reference. Joined emoji keep their zero-width joiner characters, so they reassemble when decoded.
- What actually needs escaping. In element content, & and < are enough; inside attribute values, also the quote that delimits the value. OWASP's XSS prevention rules add that escaping for HTML is not enough inside <script>, URLs or CSS, which need their own encoding.
- With UTF-8 pages most entities are optional. Characters like é, © and € can be typed directly; entities mainly help for invisible or confusable characters such as or ­.
Sources
Checked on .
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools