HTML Entity Encoder
Encode and decode named, decimal, and hexadecimal HTML entities.
- Recent results are kept in this browser's local storage until you clear them.
History kept on this device
Recent results are kept in this browser's local storage until you clear them. - Processing happens in this page. No application server receives your input.
Runs in your browser
Processing happens in this page. No application server receives your input.
Input
Output
What this tool does
This tool converts text between raw Unicode characters and XML/HTML character references entirely in your browser with zero network requests. When embedding user-supplied strings, code snippets, or markup fragments into HTML documents, attributes, or XML payloads, reserved syntax characters must be escaped as character references so that the parser treats them as literal text rather than executable tags or attribute delimiters.
In Encode mode (minimal), <a href="x"> becomes <a href="x">. In Decode mode, decimal numeric entity 😀 (or hexadecimal 😀) decodes to 😀.
Encoding levels
- Minimal (
minimal): Escapes only the five XML syntax characters:&(&),<(<),>(>),"("), and'('). All other ASCII and Unicode characters remain untouched. - Non-ASCII (
nonAscii): Applies the minimal XML escapes and additionally converts every code point aboveU+007Finto a decimal numeric reference&#N;. Supplementary astral-plane characters (U+10000..U+10FFFF) are iterated by full Unicode code point (for (const ch of input)) so each astral character emits a single&#NNNNN;entity rather than a split UTF-16 surrogate pair. - All (
all): Encodes every character in the input string as its decimal numeric reference&#N;by code point.
Supported entities on decode
Decode mode resolves the five XML named entities (<, >, ", ', and &), decimal numeric references (😀, '), and case-insensitive hexadecimal numeric references (😀, 😀). Any numeric reference outside the valid Unicode scalar range (above U+10FFFF or within the UTF-16 surrogate block U+D800..U+DFFF) is rejected with an inline error while preserving your last valid output.
Security note: no double-unescaping
Decoding runs in a single left-to-right pass so decoded characters are never re-parsed as new entity tokens (GAP-039). Evaluating decodeHtml(encodeHtml('<')) or decoding &lt; and &lt; always yields the literal four-character string < and never collapses a second time into <.
Limits
Decodes the 5 XML named entities plus numeric entities; does not include the full 2,200+ HTML5 named entity table (use T16 Unicode Inspector for code point lookup).
Inputs up to 1.0 MB run synchronously on the main thread, and payloads above 16.0 MB are refused before allocation.
Scope: this covers the page itself. Your browser, operating system, clipboard, downloads, extensions, and crash recovery may keep copies, and a compromised site origin would not be protected.