HTML Entity Encoder / Decoder
Encoding Tools
Encode special characters to HTML entities and decode them back. Supports named (&), decimal (&), and hex (&) entity styles. Runs entirely in your browser.
What are HTML entities?
An HTML entity is a text string that begins with an ampersand (&) and ends with a semicolon (;). Entities represent characters that have special
meaning in HTML markup, such as the less-than sign (<) and the ampersand
itself, or characters that are difficult to type directly, such as non-breaking spaces or
accented letters.
Without entity encoding, a stray < or & in text content can confuse
the browser's HTML parser, causing rendering errors or, in the worst case, creating an XSS vector
when user-supplied text is inserted into a page.
Named, decimal, and hex entities
HTML5 supports three entity formats, all of which produce identical output in the browser:
- Named: uses a mnemonic name:
&,<,>,",', . Named entities exist only for a fixed set of characters. For all other characters this tool falls back to hex notation. - Decimal: uses the Unicode code point in base 10:
&for&,<for<. Works for any Unicode character. - Hex: uses the code point in hexadecimal:
&for&,<for<. Preferred in CSS and SVG contexts and by most minifiers.
Which characters are encoded?
This tool encodes characters that require escaping for safe HTML output:
-
&->&: must always be escaped -
<-><: prevents accidental tag interpretation -
>->>: prevents closing tag confusion -
"->": safe inside double-quoted attributes -
'->': safe inside single-quoted attributes - All non-ASCII characters (code points above U+007F): ensures ASCII-only HTML source compatibility
Common use cases
- Sanitizing user input for HTML insertion: encode text content before inserting it into a web page to prevent cross-site scripting (XSS).
- Writing HTML by hand: encode special characters in content so the browser renders them literally rather than interpreting them as markup.
- Debugging encoded HTML: paste a snippet full of entities into Decode mode to read it as plain text.
Security framing: XSS prevention
Failing to HTML-encode user-supplied input before inserting it into the DOM is the root
cause of Cross-Site Scripting (XSS), consistently ranked as one of the most
common and impactful web vulnerabilities (OWASP Top 10). An attacker who can inject
<script> tags or event handlers via unescaped input can steal session cookies,
redirect users, or perform actions on their behalf. Always encode output at the point of insertion
- not just at the point of input.
Content Security Policy (CSP)
HTML entity encoding alone is not sufficient to prevent all XSS attack vectors. Browsers
support a Content-Security-Policy response header that specifies which sources
of scripts, styles, and other resources are trusted. A strict CSP (e.g.,
script-src 'self') provides a critical defense-in-depth layer that limits the
damage if encoding is missed or bypassed. Use both encoding and CSP together.
More encoding tools
- Base32 EncoderEncode and decode text or binary data using Base32 (RFC 4648 standard, Base32hex, or Crockford variant). Copy output with one click. Runs entirely in your browser.
- Base64Encode text or files to Base64 online: standard, URL-safe, and Base64url variants. Decode back to text or download as a file. All processing is local.
- Binary Text EncoderConvert any UTF-8 text to binary (8-bit groups) or decode binary back to text. Choose your separator format. Free, instant, browser-only.
- Punycode EncoderEncode Unicode / internationalized domain names (IDN) to Punycode (xn--) and decode them back. Implements RFC 3492 entirely in the browser.
- QR CodeGenerate QR codes for URLs, text, Wi-Fi, vCards, email, SMS, phone, geo, crypto, and calendar events. Customize colors, size, and error correction. Download as PNG or SVG.
- Quoted-Printable EncoderEncode text to Quoted-Printable (QP) or decode QP back to plain text. Implements RFC 2045 Section 6.7 with proper 76-char line wrapping.