What is the HTML Entity Encoder & Decoder?
The HTML Entity Encoder & Decoder is a web security and typography utility that translates reserved HTML markup characters (`<`, `>`, `&`, `"`, `'`), typographic symbols (`©`, `®`, `™`, `—`, `€`), and international Unicode glyphs into safe HTML character entity references—and decodes escaped HTML strings back into clean plain text. Whenever you display code snippets inside an HTML `<code>` block or render untrusted user input, unescaped `<` and `&` characters can break the DOM structure or open the door to Cross-Site Scripting (XSS) vulnerabilities.
Unlike single-mode escapers that only handle the 5 basic XML characters, our encoder offers three distinct encoding formats: **Named HTML Entities** (`&`, `<`, `©`, `€`, `—`), **Numeric Decimal Entities** (`&`, `©`, `€`), and **Numeric Hexadecimal Entities** (`&`, `©`, `€`). You can also choose whether to encode only reserved/non-ASCII characters (keeping normal English text readable) or encode every single character in the string.
Alongside bidirectional live encoding and decoding, the workspace features an interactive HTML Entity Reference Cheat Sheet covering essential XML/XSS characters, currency symbols, mathematical operators, arrows, and typography marks with one-click copy buttons for Named, Decimal, and Hex codes.
How to Use HTML Entity Encoder & Decoder (Step-by-Step)
- 1
Enter Plain Text or HTML Entities
Type or paste unescaped text/code into the Plain Text box to encode it, or paste escaped HTML (`<div>`, `©`, `🚀`) into the Encoded box to decode it.
- 2
Choose Entity Format (Named, Decimal, or Hex)
Select Named Entities (`©`), Numeric Decimal (`©`), or Numeric Hexadecimal (`©`) depending on whether you are targeting HTML5, XML, or email clients.
- 3
Select Encoding Scope
Choose 'Special & Non-ASCII Only' (escapes `< > & " '` and symbols while keeping normal letters readable) or 'Encode All Characters' for full obfuscation.
- 4
Browse the Common HTML Entities Reference Table
Search or scan the built-in cheat sheet below to look up copyright, trademark, non-breaking space (` `), arrows, and math symbols.
- 5
Copy Escaped or Decoded Output
Click Copy on either panel to paste safe HTML code directly into your template, blog post, or documentation.
Key Features of Our HTML Entity Encoder & Decoder
Three Entity Encoding Formats
Switch seamlessly between W3C Named Entities (`©`), Decimal Numeric (`©`), and Hexadecimal Numeric (`©`).
Selective vs. Full-String Encoding Scope
Escape only HTML-unsafe and non-ASCII characters for clean code blocks, or encode every alphanumeric character into numeric entities.
Universal Entity Decoder
Decodes all Named entities, decimal `&#NNN;` codes, and hexadecimal `&#xHHH;` codes (including multi-byte Astral plane emojis) in a single pass.
Comprehensive Named Entity Dictionary
Maps syntax delimiters, typographic punctuation (`—`, `…`), currencies (`€`, `£`, `¥`), math operators, and Greek letters.
Astral Plane Unicode (`codePointAt`) Accuracy
Uses true Unicode code points (`String.fromCodePoint`) rather than broken UTF-16 surrogate halves when encoding emojis like `🚀` (`🚀`).
Interactive Symbol Reference Table
Includes a searchable reference table of the most frequently used HTML entities with instant copy buttons.
Key Benefits & Advantages
Display Code Snippets Safely in HTML
Escape `<script>`, `<div class="...">`, and JSX tags so browsers display them as literal text inside `<pre><code>` blocks instead of executing them.
Prevent Broken Characters in HTML Emails
Legacy email clients often garble raw UTF-8 symbols like `©`, `—`, and `€`. Converting them to `©` or `€` guarantees consistent rendering.
Sanitize User Input Against XSS
Understand and verify how escaping the 5 core HTML characters (`&`, `<`, `>`, `"`, `'`) neutralizes script injection payloads.
Clean Up Double-Encoded CMS & RSS Strings
Quickly decode messy API titles containing `&#039;`, `"`, or `’` back into clean human-readable typography.
Common Real-World Use Cases
Technical Blogging & Documentation
Prepare raw HTML, XML, or Vue/React snippets to paste safely inside `<pre><code>` tags without triggering browser rendering.
HTML Email Template Development
Convert curly quotes, em-dashes, trademarks, and currency signs into safe HTML entities that survive legacy SMTP gateways.
CMS, RSS & Scraper Data Cleaning
Decode scraped web text or WordPress REST API responses littered with `–`, `&`, and ` ` entities.
XML & SVG Attribute Escaping
Use Decimal or Hex numeric entities in strict XML/SVG files where HTML named entities beyond `& < > " '` are not defined.
How HTML Entity Encoder & Decoder Works Technically
In the WHATWG HTML Living Standard, a character reference begins with an ampersand (`U+0026 AMPERSAND`) and terminates with a semicolon (`U+003B SEMICOLON`). There are three syntactic forms: Named character references (`&name;`), Decimal numeric character references (`&#D;`, where $D$ is one or more base-10 ASCII digits representing the Unicode code point), and Hexadecimal numeric character references (`&#xH;` or `&#XH;`, where $H$ is one or more base-16 hexadecimal digits).
Because JavaScript strings are internally encoded as UTF-16 code units, characters in the Unicode Supplementary Planes (`U+10000` to `U+10FFFF`, such as emojis) are stored as a pair of 16-bit surrogate halves. Iterating via a traditional `for (let i = 0; i < str.length; i++)` loop with `str.charCodeAt(i)` would split a single emoji into two broken surrogate entities. Instead, our encoder iterates over true Unicode scalar values using `for (const char of str)` and extracts the full 21-bit code point via `char.codePointAt(0)`, generating accurate decimal (`🚀`) and hex (`🚀`) entities.
Expert Tips for Best Results
- When escaping strings in code, always replace `&` with `&` FIRST before replacing `<` or `>`—otherwise you will turn `<` into `&lt;` (double-encoding)!
- Strict XML and standalone SVG files only recognize 5 named entities (`&`, `<`, `>`, `"`, `'`). For any other symbol in XML/SVG (like `©`), use Numeric Decimal (`©`) or Hex (`©`).
- Use ` ` (` `, non-breaking space) between a number and its unit (like `100 MB` or `$50 million`) so they never split across an awkward line wrap.
- In HTML5, single quotes can be escaped as `'`, `'`, or `'`; using `'` is the most universally compatible across older XML/HTML parsers.
- If your text shows `&amp;` or `&#8217;`, it was double-encoded—click Decode twice (or copy the decoded result back to input) to restore the original text.
100% Local Browser Privacy Guarantee
All HTML entity encoding and decoding executes 100% locally in your browser. Your markup snippets and text never leave your computer.
Frequently Asked Questions About HTML Entity Encoder & Decoder
What are the 5 essential HTML characters that must always be escaped for security?+
To prevent HTML breakage and Cross-Site Scripting (XSS) in element bodies and quoted attributes, you must always escape five characters: `&` (`&`), `<` (`<`), `>` (`>`), `"` (`"`), and `'` (`'` or `'`).
What is the difference between Named, Decimal, and Hex HTML entities?+
They all render the exact same character! For example, the Copyright symbol (`©`) has Unicode code point 169 (`0xA9` in hex). You can write it as Named (`©`), Decimal (`©`), or Hexadecimal (`©`). Named entities are easier to read, while Decimal/Hex work for every single character in Unicode.
Why did my XML or SVG file break when I used or ©?+
Unlike HTML5 (which defines over 2,000 named entities), the strict XML 1.0 specification only defines 5 named entities: `&`, `<`, `>`, `"`, and `'`. In XML or SVG files, always use Numeric Decimal (` ` for nbsp, `©` for copy) or Hex (` `, `©`).
What is and how is it different from a regular space?+
` ` stands for Non-Breaking Space (`U+00A0`, ` `). Unlike regular spaces—where browsers collapse multiple consecutive spaces into one and allow line wrapping—` ` prevents the browser from breaking a line between two words and preserves multiple spaces.
Why do I see ’ or ' in text copied from WordPress or RSS feeds?+
`'` is the numeric entity for a straight apostrophe (`'`), and `’` is the numeric entity for a curly right single quote (`’`). Content management systems escape them in database/JSON feeds; pasting them into our Decoder converts them back into normal readable punctuation.
Can I encode an entire email address into HTML entities to stop basic spam bots?+
Yes! Switch the Scope option to 'Encode All Characters' and choose Decimal or Hex mode. It will convert every letter of `mailto:you@domain.com` into numeric character references that browsers render normally for humans.