Developer
HTML Entity Escape and Unescape
Escape markup so it displays as text, or decode entities back - without ever rendering them.
Runs entirely in your browser. Nothing you paste is uploaded.
0 characters · 0 bytes
This runs entirely in your browser. Nothing you paste is sent to us or to anyone else.
How to use it
- Paste your text into the box marked "Text or markup to escape"Paste the text or markup. Escape and Unescape switch direction. Everything happens inside your browser — nothing is uploaded, so there is nothing for us to store, log or lose.
- Read the result as it updatesThere is no button to press. The conversion happens as you type. The output recomputes every time you change the text or one of the options above it.
- Escape when you are putting text INTO a pageIt turns < > & " into their entities so they display as characters rather than being parsed as markup. This is the operation that stops somebody else's text becoming somebody else's HTML.
- Unescape when you are reading markup OUTIt turns &amp; and &#160; back into the characters they stand for — useful when a value has been escaped twice on its way through a system.
- Do not treat escaping as sanitisingEscaping makes text safe to DISPLAY. It does not make untrusted HTML safe to insert into a page — that needs an allowlist sanitiser, which this is not.
- Copy or download the resultThe buttons under the output put it on your clipboard or save it as a file, and each one says exactly what it will copy or download. Any note about something the tool changed or deliberately left alone is shown with the result rather than hidden.
About this tool
HTML entity escaping replaces the five characters that carry meaning in HTML — & < > " ' — with their entity forms, so that text is displayed as text rather than interpreted as markup. It is the mechanism behind preventing cross-site scripting when user content is rendered into a page.
Unescaping goes the other way, turning &, — and — back into the characters they stand for. It is what you need when a feed, an export or a database column has been escaped twice and now shows &amp; on screen.
Understanding the result
Escaping converts & first and the rest after, which is the order that avoids double-escaping the ampersands it has just introduced.
The apostrophe is written as ' rather than '. ' is not defined in HTML 4 and older parsers display it literally.
Unescaping handles named entities, decimal (©) and hexadecimal (©) forms. Anything it does not recognise is left exactly as it was rather than guessed at.
Example
Input
<a href="?a=1&b=2">Tom & Jerry's</a>Output
<a href="?a=1&b=2">Tom & Jerry's</a>Limitations
- Escaping text is not by itself sufficient protection against XSS. Content placed inside a script tag, a style block, an event handler attribute or a URL attribute needs the escaping rules for that context, not this one.
- The named-entity table covers the entities that appear in real documents, not all 2,231 in the HTML standard. The numeric forms are handled completely, and the long tail almost always arrives numeric.
- This tool does not parse HTML. It escapes and unescapes characters; it will not tell you whether your markup is well formed.
- Decoding is deliberately not done by assigning to innerHTML — the usual shortcut — because that executes scripts in the pasted markup. That is why the entity table exists.
Questions
Is my data uploaded anywhere?
No. The whole tool is JavaScript running on your device — there is no request to send. You can confirm it by opening your browser's network tab, or by disconnecting from the internet and using the page anyway.
Is it safe to paste untrusted HTML in here?
Yes. The decoder is a lookup table and a numeric parser, not the browser's HTML engine. The common implementation — setting innerHTML on a hidden element and reading the text back — would run any script in what you pasted. This one cannot.
Why do I see &amp; on my website?
Because the text was escaped twice: an already-escaped "&" was escaped again into "&amp;". Unescape it once here and you will get "&"; twice and you will get "&". Then fix the pipeline so it only escapes at the point of output.
Does escaping make my site safe from XSS?
It is the most important part, but the correct escaping depends on where the value lands. Inside an ordinary element, this is right. Inside an attribute, a script, a style or a URL, the rules differ — and no escaping fixes a value used as a whole URL that starts with "javascript:".
Last updated 2026-08-16.