Encode or decode HTML entities in named, decimal, or hex format. Swap encode ↔ decode with one click — runs entirely in your browser.
Output will appear here
HTML entity encoding is a vital security and formatting technique that converts reserved HTML characters into character references (such as & or <).
This prevents user-provided input from being executed as active browser markup, eliminating Cross-Site Scripting (XSS) injection attacks and ensuring special typography displays accurately.
| Character | Entity Name | Decimal Code | Hexadecimal Code | Description |
|---|---|---|---|---|
& | & | & | & | Ampersand sign |
< | < | < | < | Less-than sign (opening tag) |
> | > | > | > | Greater-than sign (closing tag) |
" | " | " | " | Double quotation mark |
' | ' | ' | ' | Apostrophe / single quote |
© | © | © | © | Copyright symbol |
€ | € | € | € | Euro currency symbol |
£ | £ | £ | £ | British Pound sterling symbol |
©, —): Human-readable and intuitive to write in source files, but limited to entities recognized by HTML specifications.©): Directly references Unicode code points in base-10.©): Directly references Unicode code points in base-16; universal across XML, XHTML, and HTML.JavaScript
// Safe entity encoding function
function encodeHtmlEntities(rawString) {
return rawString.replace(/[&<>"']/g, (char) => {
const map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
};
return map[char];
});
}
// Entity decoding function
function decodeHtmlEntities(encodedString) {
const doc = new DOMParser().parseFromString(encodedString, 'text/html');
return doc.body.textContent || "";
}
Python (html module)
import html
unsafe = '<div class="alert">Notice: 5 > 2 & 10 < 20</div>'
safe_html = html.escape(unsafe)
print(safe_html)
# Output: <div class="alert">Notice: 5 > 2 & 10 < 20</div>
&amp;.<meta charset="utf-8"> at the start of HTML documents to prevent character encoding confusion attacks.This website and utility are provided for general informational, calculation, and educational purposes only. Always verify critical computation outputs prior to professional deployment or financial use. See our Terms of Service and Privacy Policy for full governance details.