HTML Entity Encoder / Decoder
Encode text as HTML entities or decode entities back to plain text. 100% client-side.
How to Use the HTML Entity Encoder
- Paste your text or HTML into the input area on the left.
- Choose a mode — Encode (essential characters), Decode, Encode All (every character), or Named Entities.
- View the result — the converted output appears instantly on the right.
- Copy or download — use the buttons above the output to copy or save the result.
What Are HTML Entities?
HTML entities are special text sequences used to represent characters that have special meaning in HTML or that cannot easily be typed directly. Every entity begins with an ampersand (&) and ends with a semicolon (;). The most important entities for web developers are the five characters that must be escaped to prevent browsers from misinterpreting them as HTML markup: < (less-than), > (greater-than), & (ampersand), " (double quote), and ' (single quote / apostrophe).
The Four Encoding Modes
- Encode — replaces only the five essential characters (
<>&"') with their safe entity equivalents. This is the standard mode for escaping user input before inserting it into HTML. - Decode — converts HTML entities back to their original characters. Handles named entities like
, decimal numeric references like©, and hexadecimal numeric references like©. - Encode All — converts every character to its numeric entity (
&#NNN;). The output is much longer but is safe in any HTML context. This is sometimes used to obfuscate email addresses from spam crawlers. - Named Entities — like Encode but also replaces additional characters with their named HTML entities where available (e.g.,
©for ©,—for —, for non-breaking space).
Why HTML Entity Encoding Matters for Security
Failing to encode HTML entities is one of the most common causes of cross-site scripting (XSS) vulnerabilities. If a user submits text containing <script>alert('XSS')</script> and your application inserts it directly into an HTML page without encoding, the browser will execute that script. Proper HTML entity encoding neutralizes this attack by converting the angle brackets to < and >, which the browser renders as literal text rather than markup. Modern server-side frameworks and templating engines usually handle this automatically, but whenever you are setting innerHTML in JavaScript or constructing HTML strings manually, you must encode any user-supplied values yourself.
Common Named HTML Entities
&— & (ampersand)<— < (less-than sign)>— > (greater-than sign)"— " (double quotation mark)'— ' (apostrophe) — non-breaking space©— © (copyright sign)®— ® (registered sign)™— ™ (trademark sign)—— — (em dash)–— – (en dash)€— € (euro sign)
HTML Entities vs. URL Encoding
HTML entity encoding and URL encoding are different things that serve different purposes. HTML entity encoding makes text safe to display inside HTML documents. URL encoding (percent-encoding) makes text safe to use inside a URL. For example, a space in an HTML document can be represented as (non-breaking space entity) or simply left as a space (regular spaces are fine in HTML content). But a space in a URL must be encoded as %20. Use our URL Encoder for URL encoding tasks, and this tool for HTML entity encoding.