HTML Decode
Decode HTML entities back into their original characters.
Convert special characters like less-than, greater-than, ampersand, and quotes into safe HTML entities to prevent markup injection and display code as text. Everything runs 100% client-side in your browser.
An HTML parser reads a document looking for structure. When it sees a less-than sign it assumes a tag is starting, and when it sees an ampersand it assumes an entity reference is starting. If your content genuinely contains those characters as text, the parser has no way to tell the difference, and your paragraph about "a < b" silently becomes a malformed element.
Entities solve this by giving every problem character an alternative spelling that contains no structural characters. An entity begins with an ampersand, names the character either by keyword or by code point number, and ends with a semicolon. The parser resolves it back to the original character at the moment it builds the text node, so the reader sees exactly what you intended.
Five characters do the damage. Two of them, the ampersand and the less-than sign, are dangerous anywhere in an HTML document. The others matter depending on where the text lands.
Order is not optional. If you escape the less-than sign before the ampersand, the ampersand you just introduced gets escaped again and < turns into &lt; which renders as visible text rather than a symbol. Always replace the ampersand first, then everything else.
Escaping user input before it reaches a page is the primary defence against cross-site scripting. An attacker who can get raw markup into your HTML can run JavaScript in your users' sessions. Encoding removes the ability of the input to change the shape of the document.
The critical subtlety is that escaping is context dependent. There is no single correct encoding, only the correct encoding for the place the value lands:
The same character can be written three ways. All three render identically, and the choice is about readability and compatibility.
XML predefines only five names (amp, lt, gt, quot, apos), so anything generating XML, RSS, or SVG should prefer numeric references. Note also that ' was added in HTML5 and is unreliable in very old HTML4 parsers, which is why security libraries tend to emit ' for the apostrophe instead.
Named entities are easier to read, numeric entities work everywhere including XML where only five names are predefined. Both forms always end with a semicolon.
| Character | Named entity | Numeric entity | Description |
|---|---|---|---|
| & | & | & | Ampersand |
| < | < | < | Less than, opens a tag |
| > | > | > | Greater than, closes a tag |
| " | " | " | Double quotation mark |
| ' | ' | ' | Apostrophe or single quote |
| (space) | |   | Non-breaking space |
| © | © | © | Copyright sign |
| ® | ® | ® | Registered trademark sign |
| ™ | ™ | ™ | Trademark sign |
| – | – | – | En dash |
| … | … | … | Horizontal ellipsis |
| € | € | € | Euro sign |
| £ | £ | £ | Pound sign |
| ° | ° | ° | Degree sign |
| × | × | × | Multiplication sign |
Working on something related? Browse every free developer tool on the site, including a HTML decoder, URL encoder, Base64 encoder, and text utilities. Everything runs entirely in your browser, so nothing you paste is ever uploaded.
Any time text you do not fully control ends up inside an HTML page, it needs to be encoded first. Without encoding, a stray angle bracket can break your layout, and a malicious script tag can hijack your users. This HTML encoder converts the reserved characters (less-than, greater-than, ampersand, and both quote styles) into their entity equivalents so the browser renders them as plain text. It is the right tool for escaping user input before display, preparing code snippets for documentation, and hardening templates against cross-site scripting. Processing happens entirely in your browser, so nothing you paste is ever uploaded.