Escape raw <, >, &, ", and ' markup into safe HTML5 entities (with optional non-ASCII numeric decimal or hex encoding) or decode named and numeric entities like — and 🚀 back into readable UTF-8 text.
Interpolating unescaped user strings into HTML emails, RSS XML feeds, or server-rendered templates opens immediate Cross-Site Scripting (XSS) vulnerabilities and breaks attribute boundaries whenever text contains quotes or ampersands.
Conversely, scraped metadata, CMS exports, and RSS titles frequently arrive littered with &quot; double-encoding or numeric code points like ’. This tool handles both minimal security-safe escaping and full non-ASCII entity conversion in either direction.
HTML Escaping & Encoding Pitfalls
01. Forgetting Single Quotes (') Inside HTML Attributes
Escaping only <, >, and " leaves single-quoted attributes like title='user input' vulnerable to attribute breakout. Always encode apostrophes as ' (avoid ' for legacy HTML4/email clients).
02. Double-Escaping Ampersands (&amp;)
Running an encoder twice over already-escaped copy converts © into &copy;, rendering literal entity code on screen. Decode once to inspect the real underlying string before re-encoding.
03. Using HTML Entities Inside JavaScript or CSS Contexts
HTML entity encoding protects HTML element body and attribute contexts only. Placing HTML-encoded text inside a <script> block or inline onclick handler does not stop JS injection—use JSON serialization instead.
Core Reserved HTML5 Character Entities
| Character | Named / Safe Entity | Numeric Hex |
|---|---|---|
| & (Ampersand) | & | & — must always be escaped first |
| < (Less Than) | < | < — prevents opening arbitrary tags |
| > (Greater Than) | > | > — closes tag injection payloads |
| " (Double Quote) | " | " — secures double-quoted attributes |
| ' (Apostrophe) | ' | ' — safer than ' in old mailers |
Worked Engineering Examples
Neutralizing an Injected Script Tag
<img src="x" onerror="alert(1)">
<img src="x" onerror="alert(1)">
Browsers display the string verbatim as harmless text instead of executing the onerror attribute.
Decoding Numeric Unicode Emoji & Typography
Launch — 100% Ready 🚀
Launch — 100% Ready 🚀
Resolves named entities, decimal NCRs, and supplementary-plane hexadecimal code points via String.fromCodePoint.
Frequently Asked Questions
Should I encode non-ASCII characters like Chinese or Emoji as HTML entities?
If your page declares <meta charset="utf-8">, raw UTF-8 characters are smaller and cleaner. Turn on Encode Non-ASCII only for legacy ISO-8859-1 email gateways or ASCII-only XML pipelines.
Why does the encoder emit ' instead of '?
Although HTML5 and XML support ', older email clients and HTML4 parsers fail to decode it. Numeric ' works universally across every browser and mail client.
Does the decoder handle supplementary Unicode emoji like 😀?
Yes. Code points above U+FFFF are decoded with String.fromCodePoint after validating the 0x0–0x10FFFF Unicode range.
How do I fix double-escaped RSS titles like Tom &amp; Jerry?
Paste the string in Decode mode once to get Tom & Jerry, click Swap, and decode a second time to restore Tom & Jerry.