HTML Escape and Unescape
Turn HTML into safe entities for display — or turn entities back into markup. Escape and unescape in both directions, with the five core entities handled correctly.
Runs in your browser — your code and data never leave this device
How do I escape HTML entities online?
Paste your code here: this free online HTML entities encoder turns markup into safe entities for display — or decodes entities back to code. Escaping converts the five characters that have special meaning in HTML, and unescaping uses your browser's own decoder, so named and numeric entities all decode. Nothing is uploaded.
Related tools
How to use the HTML Escape and Unescape
- Paste your HTML code or your escaped text into the Input box, or click Sample to load an example.
- Click Escape HTML to turn markup into entities, or Unescape HTML to turn entities back into characters.
- The result appears on the right. Run the opposite button on it to get back exactly what you started with.
- Copy the result or Download it as a text file.
For the full picture — why HTML needs escaping, the five entities, and how escaping differs from URL encoding — read our guide: How to Escape HTML (Free HTML Entity Encoder).
Why HTML needs escaping
A browser reads angle brackets as the start of a tag, so if you want to show the text <div> on a web page, you cannot write it as-is — the browser will treat it as a real div and show nothing. Escaping replaces the five characters that have special meaning in HTML — the ampersand, less-than, greater-than, double quote and single quote — with entities the browser displays as text instead of interpreting as code.
The classic case is a tutorial page that shows code examples. Every tag in the example must be escaped, or the example vanishes into the page and may even break the layout around it. The same applies to user comments, forum posts and any place where text typed by a person is shown on a page: escaping is what keeps a typed <script> tag harmless.
The five entities this tool uses
The ampersand becomes &, the less-than sign becomes <, the greater-than sign becomes >, the double quote becomes ", and the single quote becomes '. The ampersand is always escaped first, because the other entities contain ampersands themselves — escape it last and you would double-escape everything into &lt; and similar nonsense.
Unescaping works the other way: the browser itself decodes the entities, so every named entity and numeric character reference is handled, not just the five this tool writes. That means © becomes the copyright sign and © does too. If your text contains an entity the browser does not recognise, it is left as-is rather than guessed.
Named entities and numeric references do the same job in different ways. A named entity like © is easy to remember, while a numeric reference like © works for any character, including ones with no name at all. Older HTML documents used numeric references heavily, and you will still meet them in content copied from old sites or exported from databases. Both forms display identically, so when you unescape text you do not need to care which form it used — the result is the same character.
Escaping is not the same as encoding a URL
HTML escaping and URL encoding solve different problems and are not interchangeable. Escaping makes text safe to show inside a page; URL encoding makes text safe to put inside a web address, turning spaces into %20 and slashes into %2F. Using the wrong one produces broken links or visible percent codes in your text.
For links, use the URL and HTML Encoder, which handles both. For displaying code or user text on a page, this tool is the right one. And remember that escaping is a display step, not a security product on its own: a website that takes user input still needs proper handling on the server side, but escaping is the first and most important layer.
Escape and unescape: the five characters and the full decoder
Escaping changes five characters: the ampersand, the less-than and greater-than signs, the double quote and the apostrophe. Those five are the ones that can break a page or be read as markup, so they are written as entities instead — and the ampersand is escaped first, so the entities themselves are not escaped a second time. Use the escape direction whenever you want to show code, maths or quoted markup as text on a web page.
Unescaping works the other way: paste text full of entities and get the original characters back. Because the decoder is your browser's own, it understands named entities and numeric entities alike — not just the five this tool writes. One distinction to keep straight: escaping is not the same as encoding a URL. Escaping is for text inside a web page; URL encoding is for characters inside a web address, and the two are not interchangeable.
Frequently asked questions
Which characters does escaping change?
Five: the ampersand becomes the amp entity, less-than becomes lt, greater-than becomes gt, the double quote becomes quot, and the single quote becomes the numeric entity 39.
Why is the ampersand escaped first?
Because every entity starts with an ampersand. Escape it last and the other entities get escaped again, turning lt into amp lt, which displays as text instead of a less-than sign.
Can I unescape entities this tool did not write?
Yes. Unescaping uses the browser decoder, so named entities like copy and numeric references like 169 are all decoded correctly.
Is escaping enough to make user input safe on my website?
It is the essential first layer, but a real website also needs server-side handling. Escaping stops markup from breaking your page; it is not a complete security solution on its own.
Is my text uploaded anywhere?
No. This tool runs entirely in your browser using JavaScript. Your text is never uploaded, stored or sent anywhere — everything stays on this device.
What is the difference between escaping HTML and encoding a URL?
Escaping is for text inside a web page: it turns characters such as the less-than sign into entities so the browser displays them as text instead of reading them as markup. URL encoding is for characters inside a web address, where spaces and special characters must be written in a different form so the link still works. They solve different problems and are not interchangeable.
Does escaping change how my text looks?
No. An entity displays as exactly the character it stands for — the browser renders it the same way. Escaping only changes the source code, so the text is safe to place inside HTML markup.
When should I escape HTML?
Whenever you want to show markup as text: code samples in a blog post or documentation, maths expressions with less-than signs, or quoted HTML in a tutorial. Escaping keeps the browser from reading your example as real markup — but on its own it is not a complete security solution for user input on a website.