HTML Escape and Unescape
ED-45Paste text and click HTML escape to turn the characters that matter in markup into entities. Click HTML unescape to turn entities such as & back into characters.
Runs in your browser. Nothing is uploaded.
Text or HTML
Result
How to use it
- Paste your text or HTML into the input box.
- Choose whether to escape only the five markup characters, or all non-ASCII characters as well, and in which form.
- Click HTML escape or HTML unescape.
- Copy the result, or download it as a text file.
What gets escaped
HTML escape always converts & to &, < to <, > to >, a double quote to " and an apostrophe to '. These are the characters that can change how a browser reads markup. With the second option every character above U+007F is also written as an entity, using a name such as é where the built-in table has one, otherwise a decimal or hex number.
What unescape understands
HTML unescape decodes decimal references like é, hex references like é and the named entities in the built-in table. HTML defines about 2,200 names, so a name that is not in the table is left exactly as typed instead of being guessed. Names need the closing semicolon. The tool does not parse tags, remove markup or sanitize anything.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
is not a valid Unicode character | A numeric reference is zero or above 1114111. | Use a reference between 1 and 1114111 (10FFFF in hex). |
is half of a surrogate pair | A numeric reference points to half of a UTF-16 pair, which is not a character by itself. | Write the whole character as one reference, for example 😀. |
Questions people ask
How do I escape HTML characters?
Paste the text and click HTML escape. The five characters & < > " and ' are replaced with entities, so the text shows literally on a page instead of being read as markup. Tick the non-ASCII option if you also want accented letters and symbols converted.
How do I unescape HTML entities?
Paste the text with entities such as < or é and click HTML unescape. Decimal and hex references and the common named entities are decoded. A named entity the tool does not know stays as it was typed.
Why does the apostrophe become '?
The numeric form ' works in every HTML context, while ' is not defined in old HTML 4. Using the number avoids that problem. When unescaping, both ' and ' are read back to an apostrophe.
Is escaping enough to prevent XSS?
Not always. Escaping these characters is right for text placed inside element content or a quoted attribute, but URLs, scripts and style blocks need different handling. Treat this tool as a way to show text literally, not as a complete security measure.
Does the tool remove HTML tags?
No. Escape turns the angle brackets of tags into < and >, so the tags are shown as text, and unescape turns them back. If you want the text without tags, use an HTML to text tool instead.
About this tool
Escape always converts & < > " and ' so the text shows literally inside HTML; the apostrophe becomes '. The second option also converts every character above U+007F, as a name where the built-in table has one, otherwise as a number. Unescape reads decimal and hex references and the 258 names in the built-in table. HTML5 defines about 2,200 names, so a name outside the table is left exactly as typed. It does not parse tags, strip markup or sanitize HTML, and escaping alone is not a full defense against injection in every context. Nothing is uploaded.