HTML Escape/Unescape
HTML Escape/Unescape supports escaping and unescaping HTML entities for special characters and tag display, making it useful for user input, code examples, and safer content handling.
Input Text
Character
0 / 500,000
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
Escaping Rules & Entities
Usage Advice
Limitations & Compatibility
Privacy & Security
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