Free HTML Escape / Unescape Tool Online - Entity Encoder Decoder
630 usesHTML Entity Reference
| Character | Entity Name | Entity Number | Description |
|---|---|---|---|
| < | < | < | Less than, tag opening |
| > | > | > | Greater than, tag closing |
| & | & | & | Ampersand, entity start |
| " | " | " | Double quote, attribute delimiter |
| ' | ' | ' | Single quote, attribute delimiter |
|   | Non-breaking space | |
| © | © | © | Copyright symbol |
| ® | ® | ® | Registered trademark |
HTML Escaping Guide
What is HTML Escaping?
HTML escaping converts special characters like < > & into entity codes, preventing browsers from interpreting them as HTML markup.
XSS Prevention
Escaping user input is critical for preventing Cross-Site Scripting (XSS) attacks, where malicious scripts get injected into web pages.
Display Code Snippets
When showing HTML source code on a web page, you must escape the tags so they display as text instead of being rendered.
Data Safety
Escape user-generated content before rendering it in HTML. Modern frameworks like React and Vue do this automatically.
Entity Formats
HTML entities come in two forms: named (<) and numeric (<). Both produce the same result — named entities are more readable.
Must-Escape Characters
Five characters must always be escaped in HTML: < > & " ' — they have special meaning in HTML syntax.
Frequently Asked Questions
Can HTML escaping protect against all XSS attacks?
Not by itself. Escaping handles output context, but XSS can also happen through JavaScript execution, CSS injection, or attribute-based attacks. You still need proper Content Security Policy headers and input validation. Think of escaping as one layer, not a silver bullet. Pair it with a CSP that blocks inline scripts for real protection.
Is there a way to escape just the angle brackets without touching other characters?
Our tool doesn't support selective escaping, and there's a good reason for that. Partial escaping leaves gaps attackers can exploit. Say you escape < and > but leave & alone. A user entering <script> would still render as a literal tag if your database double-encodes it. Run everything through the full escape once, then trust your output. You'll dodge weird edge cases.
What happens if I paste already-escaped HTML into the escape field?
The tool will escape it again, turning `&` into `&amp;`. That's usually not what you want. Always check your input starts as raw HTML characters, not entities. If you're unsure, paste a small sample first and glance at the output. This mistake trips up a lot of developers — especially when pulling text from a CMS that already escaped it once.
Why does my browser display raw HTML tags when I use <code>innerHTML</code> to insert text?
You're likely feeding the browser raw <code><</code> and <code>></code> characters through JavaScript. When you use <code>innerHTML</code>, the browser interprets them as markup, not text. Run your string through HTML escaping first — that converts <code><</code> to <code><</code> and <code>></code> to <code>></code>. Then assign the escaped version to <code>innerHTML</code>. This forces the browser to display tags as literal characters. Miss this step and you'll see broken layouts or, worse, an XSS hole you can't explain.
Do I need to escape HTML inside a <textarea> element?
Yes, you do. Many people think textareas are safe zones because they render text differently. The browser still parses HTML inside a textarea. Put raw < and > characters in there, and you'll break the page or open an XSS vector. Always escape any user content before injecting it into a textarea. Our tool handles this in seconds, turning < into < and > into > across thousands of lines.
Should I escape HTML before or after storing user input in my database?
Store raw input, escape at render time. That's the rule that saves you from double-encoding nightmares. If you escape before saving, you'll later unescape for editing, then re-escape for display — three places for bugs to creep in. Keep the database clean, then run everything through this tool right before it hits the browser. You'll avoid the mess where & becomes &amp; and your users see broken text. One exception: if you're building a static site, pre-escaping at build time works fine.
What's the difference between escaping HTML and URL encoding?
They solve completely different problems. HTML escaping converts characters like < and > into entities (<, >) so browsers render them as text, not markup. URL encoding turns characters into percent-encoded values (%3C, %3E) for safe transport in query strings and paths. Mixing them up breaks things in subtle ways. If you're building a link with user input, URL-encode the parameters. If you're displaying that same input on a page, HTML-escape it. Two separate steps, two separate tools—this one only handles HTML. A quick sanity check: if your URL shows %26 where & should be, that's encoding, not escaping. Use the right one for each layer and you'll avoid those confusing double-encoding bugs that eat hours.
Does escaping HTML mess up the formatting of my code snippets in documentation?
Only if you escape the wrong layer. Wrap your snippet in <code> or <pre> tags first, then escape the content inside. That way <div class="box"> becomes <div class="box"> and renders as visible text instead of an actual div. Writers doing this by hand for a 200-line example usually regret it. Paste the whole block into the tool, copy the output, and your indentation and line breaks survive untouched.
Will this tool break my existing code comments when I decode HTML entities?
No, decoding leaves standard code comments completely untouched unless they contain encoded characters like < or >. Paste your text into the box and the decoder processes everything in under 0.1 seconds. You'll get clean code back instantly. Always verify the output before pushing changes to production.
Can I use this tool to clean scraped messy data in Python pipelines?
Data engineers often use our tool to sanitize raw web-scraped strings before loading them into databases. You can paste up to 50,000 characters of messy HTML entities in one go and instantly decode them into readable plain text. Python scripts sometimes choke on stray `&` or `'` symbols during SQL inserts. Running the batch through this decoder first saves you hours of debugging broken data pipelines. Clean your data before saving it, not after.
How to Use
- Enter or paste HTML/text in the input box
- Click Escape to convert special characters to HTML entities
- Click Unescape to convert entities back to characters
- The HTML preview shows how the output renders in a browser
- Use Swap to quickly exchange input and output
- All processing runs locally in your browser — no data is transmitted