Free Online HTML, JavaScript and XML Escape and Unescape
Escape text so it cannot break out of HTML, a JavaScript string or an XML document, and unescape it again. Each language gets its own rules: HTML entities named or numeric, JavaScript backslash sequences including the script tag trap, and the five entities XML actually defines. Nothing is uploaded.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
How to Use Escape and Unescape Tool
Step by step, start to finish.
HTML, a JavaScript string, or an XML document. The three have different rules, and escaping for one of them is not escaping for another.
Escape text so it cannot break out, or unescape it back to what it was. The page runs as you type, with no button to press.
In HTML, only the five that matter is right almost always. In JavaScript, say which quote the string sits in. In XML, decide whether anything outside ASCII becomes a numeric reference.
Search the entities people actually look up, by name, by number or by description, and click a row to drop it into the input box.
Key Features
What this tool does, and what it does not do.
HTML entities, JavaScript backslash escapes, and the five XML entities.
A closing script tag and an HTML comment are broken up, which quotes alone do not fix.
Named, decimal and hex references, and JavaScript x, u and brace escapes.
Unescaping runs off a table in the page, so nothing can execute.
The entities people look up, with character, name, decimal and hex.
Nothing is uploaded. The page works with the network off.
About Escape and Unescape Tool
Escaping is what keeps text as text. A few characters mean something to whatever is going to read the string next, and if they are passed through untouched the reader stops treating them as content and starts treating them as structure. That is the whole of how cross site scripting works, and it is also why a single apostrophe in a surname can break a page that has worked for years. The fix is never to remove the character; it is to write it in the form that particular reader understands.
Which form depends entirely on who is reading. HTML wants entities, and in practice wants five of them. A JavaScript string wants backslash escapes, and it also wants the closing script tag broken up, which has nothing to do with JavaScript at all and everything to do with the HTML parser that gets there first. XML wants entities too, but it defines only five names and refuses a document containing any other, so text that is perfect HTML is often unusable XML. One escape button cannot serve all three, which is why this page asks where the text is going.
The unescaping is the part that took care, and not because the formats are hard. The obvious way to decode HTML entities in a browser is to let the browser do it through innerHTML, and that is a genuine security hole on untrusted text, so this page builds its own table instead and scans the string by hand. It costs more code, it is limited to the names in that table, and it cannot execute anything, which is the trade worth making.
Frequently Asked Questions
Common questions about this tool.