Skip to content

HTML escape

EncodeExperimentalLimited support. Verify anything critical.

HTML escape replaces ampersands, angle brackets, and quotes with HTML entities so a string can sit in text or a quoted attribute without being parsed as markup. It escapes only five characters, is not a full-document sanitizer, and does not parse or rewrite tags.

Skip to the tool

This tool processes text on your device. The text is not uploaded.

  • Escapes five characters only.
  • This is not a sanitiser for full HTML documents.

Steps

Paste the untrusted text

Enter the string you intend to place in an HTML text node or quoted attribute.

Run locally

Ampersand is escaped first, then `<`, `>`, `"`, and `'`, so entities are not double-escaped.

Embed the entities

Copy the result into markup that treats the value as text, not as a full HTML document sanitizer.

How to use HTML escape

Five entities only
Character Entity
& &amp;
< &lt;
> &gt;
" &quot;
' &#39;

Ampersand must be first. This does not sanitize javascript: URLs or unquoted attributes.

How it works

  1. Enter what you haveType or pick your text. Nothing is submitted anywhere.
  2. It runs in this tabThe calculation happens on your device, using your browser's own data.
  3. Take the resultRead the text, then copy or download.

Reimplemented locally. Not derived from IT-Tools source.

Basis
independent
Licence
MIT
Last reviewed

Frequently asked questions

What characters are escaped by this tool?

The tool escapes the five core HTML/XML special characters: ampersand (& -> &amp;), less-than (< -> &lt;), greater-than (> -> &gt;), double quote (" -> &quot;), and single quote (' -> &#39;).

Does HTML escaping protect against all XSS attacks?

HTML entity escaping protects text nodes and attribute values from tag injection. However, it does not sanitize dangerous URI schemes (like 'javascript:') or unquoted attribute contexts. Comprehensive defense requires context-aware sanitization.

Why is the ampersand (&) escaped first?

Escaping the ampersand first ensures that subsequent entity replacements (such as &lt;) are not accidentally double-escaped into &amp;lt;.

Is single quote represented as &apos; or &#39;?

The tool uses numeric entity '&#39;' for maximum backward compatibility across older browsers and XML/HTML parser implementations.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close