HTML Escape / Unescape
Escape or unescape HTML entities including named, decimal, and hex numeric entities.
HTML Entity Reference
| Character | HTML Entity | Named Entity |
|---|---|---|
| & | & | ampersand |
| < | < | less-than |
| > | > | greater-than |
| " | " | double quote |
| ' | ' | single quote |
| | non-breaking space | |
| © | © | copyright |
| ® | ® | registered |
| â„¢ | ™ | trademark |
When to Escape HTML
| Context | Required | Reason |
|---|---|---|
| User-generated content in HTML | Yes | Prevents XSS attacks |
| Code samples in <pre> blocks | Yes | Angle brackets would close tags |
| Attribute values | Yes | Quotes can break attributes |
| JSON in HTML <script> | Partial | Escape </script> closing tag |
| Template literals in JS | No | Use JS string escaping instead |