Online HTML Escape / Unescape Tool

Turn raw HTML into safe, displayable entities, or revert them back.

HTML Escape & Unescape

HTML Escape / Unescape converts the characters that have special meaning in HTML (&, <, >) into their entity forms so the browser shows them as text instead of running them as markup.
In attribute mode it also escapes quotes, which is the safe choice for values inside href="…", alt="…" and similar attributes.
Unescape reverses the process so you can read escaped markup again.


Load an example

Copy Download
Input: 0 characters | Output: 0 characters
Ready to escape or unescape HTML.


Introduction:

Our HTML Escape / Unescape tool is a simple, browser-based utility that converts the characters which have special meaning in HTML into their entity equivalents, and reverses the process when you need the original markup back. Escaping replaces & with &amp;, < with &lt; and > with &gt; so they appear as literal text on a page instead of being parsed as tags.

Unescaping does the opposite, turning those entities back into readable characters. This is useful whenever you want to show HTML source code on a page, or safely display user-submitted content without the browser executing it.


What This Tool Does?

Escape for Text (default): Converts only the three characters that can break HTML parsing in body text: &&amp;, <&lt;, >&gt;. Quotes are left untouched because they are harmless in normal text content.

Example: The input <a href="https://example.com?x=1&y=2">Link</a> becomes &lt;a href="https://example.com?x=1&amp;y=2"&gt;Link&lt;/a&gt;.

Escape for Attribute: Does everything the text mode does, and also escapes quotes so the result is safe inside an attribute value: "&quot; and '&#39;.

Example: The same input becomes &lt;a href=&quot;https://example.com?x=1&amp;y=2&quot;&gt;Link&lt;/a&gt;.

Unescape HTML: Reverses escaping by converting entities back into their original characters, handling &amp;, &lt;, &gt;, &quot; and &#39; (named and numeric).

Example: The input &lt;textarea&gt;Hello, world!&lt;/textarea&gt; becomes <textarea>Hello, world!</textarea>.

File Upload & Example Loader: Load a .txt or .html file into the input, or click "Load an example" to see the tool in action.

Copy & Download: Send the result to your clipboard with one click, or download it as a .txt file.

Live Statistics: Input and output character counts update as you type, so you can see how escaping changes the length of your text.


How to Use This Tool?

1. Enter your text: Type or paste HTML into the Input Text box, or upload a .txt / .html file.

2. Choose an option: Leave "Escape for text" selected to escape only &, < and >, or pick "Escape for attribute" if the result will sit inside an HTML attribute and must also escape quotes.

3. Escape or Unescape: Click "Escape HTML" to convert special characters into entities, or "Unescape HTML" to turn entities back into plain markup. The result appears in the Output Text box.

4. Copy or download: Use the Copy link to copy the result, or Download to save it as a file. Click Clear All to start over.


Examples:

Click Try it on any example below to load it straight into the Input Text box. The text on the right of each example is what Escape HTML (text mode) produces from that input. Press Escape HTML or Unescape HTML to see the result in the Output box.

Example 1: Displaying markup as code
Input
<textarea>Hello, world!</textarea>
Output (escaped, text mode)
&lt;textarea&gt;Hello, world!&lt;/textarea&gt;
Example 2: A link with a query string
Input
<a href="https://example.com?x=1&y=2">Link</a>
Output (escaped, text mode)
&lt;a href="https://example.com?x=1&amp;y=2"&gt;Link&lt;/a&gt;
Example 3: Ampersand & apostrophe in text
Input
Tom & Jerry's <b>show</b>
Output (escaped, text mode)
Tom &amp; Jerry's &lt;b&gt;show&lt;/b&gt;
Example 4: A div with a class attribute
Input
<div class="note">Price: $10 & up</div>
Output (escaped, text mode)
&lt;div class="note"&gt;Price: $10 &amp; up&lt;/div&gt;
Example 5: Multiple lines (bulk)
Input
<p>Hello & welcome</p>
<img src="x.png" alt="A & B">
Output (escaped, text mode)
&lt;p&gt;Hello &amp; welcome&lt;/p&gt;
&lt;img src="x.png" alt="A &amp; B"&gt;

When to Use This Tool?

Showing Code Snippets & Documentation: When you write tutorials, blog posts or docs, you often need to display markup such as <div> or <a href> on the page without the browser turning it into a live, clickable element. Escaping converts those characters into harmless entities so the source is visible to readers exactly as written.

Preventing Cross-Site Scripting (XSS): Any time you echo user-submitted content back into a page, a visitor could paste <script> or <img onerror=...>. Escaping that content first means < and > can never be interpreted as real tags, keeping your site and its visitors safe.

Building Safe Attribute Values: Switch to "Escape for attribute" whenever the escaped text will live inside an attribute such as href="…", alt="…" or title="…". Escaping the quotes prevents a value from breaking out of its quotes and injecting extra attributes.

Reading Escaped Output: Logs, emails and CMS previews frequently store content as entities. Paste them into the tool and click Unescape HTML to see the original, readable markup again.

Escaping vs Encoding: Escaping is the minimal, safe subset (only &, <, >, plus quotes in attribute mode). If you also need accented letters and symbols turned into entities, use our separate HTML Encode / Decode tool.


FAQs:

FAQ 1: What is HTML escaping?
Answer: HTML escaping replaces the characters that have special meaning in HTML with entity codes so they are displayed as literal text rather than interpreted as markup. This tool escapes &, < and >, and also quotes in attribute mode.

FAQ 2: What is the difference between escaping and encoding HTML?
Answer: Escaping is a subset of encoding. It converts only the characters that can break HTML parsing (&, <, >, and quotes in attribute mode). Full HTML encoding also turns accented letters, symbols and emoji into named or numeric entities. Use our HTML Encode / Decode tool for that broader conversion.

FAQ 3: When should I use "Escape for attribute" mode?
Answer: Use it whenever the escaped text will be placed inside an HTML attribute value, such as href="…" or alt="…". It additionally escapes " to &quot; and ' to &#39; so a value cannot break out of its surrounding quotes.

FAQ 4: Can I unescape text that was escaped elsewhere?
Answer: Yes. Paste any escaped string into the input and click Unescape HTML to revert &amp;, &lt;, &gt;, &quot; and &#39; back into their original characters.

FAQ 5: Does escaping protect against XSS?
Answer: Escaping the angle brackets and ampersand is the core defence: injected tags like <script> become harmless text. For values inside attributes, use attribute mode so quotes are also escaped. Always escape on output, never trust user input.

FAQ 6: Is the tool free to use?
Answer: Absolutely. The HTML Escape / Unescape tool, like every tool on text-toolz.com, is free and requires no registration.

TextToolz

The Ultimate Text Tools

TextToolz works seamlessly to let you convert and design your text. It is fast, reliable and secure. Trusted by thousands of users.