HTML Escape/Unescape
HTML Escape/Unescape
HTML Escape/Unescape: Supports HTML entity escaping and unescaping, handling special characters and tags. Auto-detects named and numeric entity formats, prevents XSS attacks, suitable for displaying user input, code examples, and secure content processing.
Quick Start
Common Scenarios
User Comments
Escape user-submitted comments to prevent XSS attacks
Blog Posts
Display HTML code examples in articles
Forum Posts
Safely display user-generated content
Chat Messages
Prevent malicious code spread through chat features
Form Data
Process and display form submission data
Code Display
Show HTML/JavaScript code snippets on web pages
Extended workflow
html entities, escape html, and unescape html can be handled in the same review flow, so you can verify results before copying or exporting.
Escaping Rules & Entities
Usage Advice
Limitations & Compatibility
Session Controls
FAQ
XSS (Cross-Site Scripting) is when attackers inject malicious scripts into web pages to steal user information or perform malicious operations. HTML escaping is a fundamental defense against XSS
Escaping is needed when displaying any user input, including comments, messages, form data, etc. Any content that might contain HTML tags needs escaping
Both represent < (less‑than). &lt; is a named entity (lt = less‑than); &#60;/&#x3C; are numeric/hex entities. In modern HTML they behave the same: use &lt; for readability; use &#60;/&#x3C; when named entities aren’t supported or for arbitrary characters/cross‑markup. Always keep the trailing semicolon (e.g., &lt;); without it, parsing may glue to following letters, e.g., “&notin” is read as “&not;”+“in” → “¬in”
No. HTML escaping only works in HTML context. JavaScript, CSS, and URL contexts require different escaping methods
This happens when content is escaped twice. First < becomes &lt;, then & is escaped to &amp;, resulting in &amp;lt;. Avoid repeated escaping
Use sanitization (not just escaping): allow‑list safe tags/attributes and filter protocols. Keep only p/br/ul/ol/li/a/strong/em/code/pre/blockquote/h1–h3; for a allow only href/title/target (protocols http/https/mailto/tel), for img only src/alt; remove style and all on* events. Recommend DOMPurify/sanitize‑html; sanitize on the server when possible; never insert untrusted content into innerHTML/dangerouslySetInnerHTML; use textContent for plain text