Escape HTML entities
Escape or unescape HTML entities (replace characters like <,>, &, " and \' with their HTML version)
About Escape HTML entities
Escapes the five characters that are special in HTML (&, <, >, " and ') into their entity form (&, <, >, ", '), and unescapes such entities back to plain text.
When you would use it
- Showing a code sample or user-provided text inside an HTML page without it being interpreted as markup.
- Reading text copied from page source or an API that arrived with entities in it.
- Preparing a value to put inside an HTML attribute.
How to use it
- To escape, type text in the first field and read the escaped version below it.
- To unescape, paste text containing entities in the second section and read the plain text.
- Copy the result.
Things worth knowing
- Escaping these five characters is what prevents cross-site scripting (XSS) when inserting untrusted text into HTML. Do it on output, with your framework's escaping function, not by hand.
- Only &, <, >, " and ' are escaped; other characters, including non-ASCII text, are left as they are, which is correct for UTF-8 pages.
- Unescaping handles the same five entities plus numeric forms such as '; named entities like ', or © are left untouched.
- Escaping is for HTML text and attributes only. Inside <script>, in URLs or in CSS, different escaping rules apply.
Frequently asked questions
- Why does ' stay as it is after unescaping?
- ' is an XML entity that older HTML did not define, so this tool, like many libraries, does not translate it. Use ' for an apostrophe in HTML.
- Do I need to escape text in a JavaScript framework like Vue or React?
- Not when using normal text bindings: they escape automatically. Only raw HTML insertion (v-html, dangerouslySetInnerHTML, innerHTML) needs manual care.