Convert special characters to HTML entities and back. Supports named entities, decimal codes, and hexadecimal codes.
| Char | Name | Decimal | Hex | Description |
|---|
URL Encoder, Base64 Encoder, JSON Formatter, Regex Tester, and 25+ more tools.
Browse All Tools →HTML entities are special codes used to represent characters that have a special meaning in HTML, or characters that cannot be easily typed on a keyboard. This tool converts between plain text and HTML entities instantly.
& — Named entity (human-readable, not all characters have names)& — Decimal numeric (works for any Unicode character)& — Hexadecimal numeric (compact for higher code points)// JavaScript — Encode
function encodeHTML(str) {
return str.replace(/[<>&"']/g, char => ({
'&': '&', '<': '<', '>': '>',
'"': '"', "'": '''
}[char]));
}
// JavaScript — Decode
function decodeHTML(str) {
const textarea = document.createElement('textarea');
textarea.innerHTML = str;
return textarea.value;
}
// Python
import html
encoded = html.escape('<div>Hello & World</div>')
decoded = html.unescape('<div>Hello</div>')
// PHP
$encoded = htmlspecialchars('<p>Hello</p>');
$decoded = htmlspecialchars_decode('<p>Hello</p>');
& → & (ampersand)< → < (less than)> → > (greater than)" → " (double quote)' → ' (single quote / apostrophe) → non-breaking space© → © (copyright)— → — (em dash)HTML entities are special codes used to represent characters with reserved meaning in HTML, such as < (less-than), > (greater-than), & (ampersand), and " (double quote). These characters would otherwise be interpreted as HTML syntax. Entities start with & and end with ;. For example, < renders as < and & renders as &.
Paste your text into the input field above and click Encode. The tool converts all special characters into their corresponding HTML entities. The most important characters to encode are < (<), > (>), & (&), and " ("). This ensures your content displays correctly and helps prevent cross-site scripting (XSS) vulnerabilities in web applications.
Named entities use a descriptive name like (non-breaking space) or © (©). Numeric entities use the character's Unicode code point: decimal like   or hexadecimal like  . Both refer to the same character. Named entities are more readable; numeric entities work for any Unicode character, even those without a named entity defined.
Yes. Encoding user-supplied input with HTML entities prevents cross-site scripting (XSS). If a user submits <script>alert('xss')</script>, encoding it as <script>... renders it as visible text rather than executing it. Always encode untrusted input before inserting it into HTML. Server-side encoding is more reliable than client-side for security-critical applications.
The five most critical entities are: < (less-than <), > (greater-than >), & (ampersand &), " (double quote "), and ' (single quote '). Common display entities include (non-breaking space), © (©), — (—), « («), and » (»). These cover the vast majority of everyday HTML encoding needs.