handy.moe

All tools / Debug tools

A digital stamp on a phone

HTML entity encode and decode

Escape text for safe use in HTML, or turn entities such as &, é and 😀 back into characters.

Runs in your browser. Pasted data never leaves it.

How to use it

  1. Paste text or HTML.
  2. Choose how much to escape and press Encode; press Decode to turn entities such as & and é back into characters.
  3. Copy the result.

Questions

Which characters must be escaped in HTML?

In text, & and < always. In attribute values add the quote you used. Escaping > is not required but is customary. Always escape user input before putting it in a page: it is the basic defence against cross-site scripting (XSS).

What is the difference between named and numeric entities?

&copy; and &#169; and &#xA9; are three ways to write ©. Named ones are readable; numeric ones work for every character. Decoding here uses your browser's own HTML parser, so every one of the 2,000+ named entities works.

Why does <code>&amp;nbsp;</code> look like a space?

It is a non-breaking space (U+00A0). It prints like a space but doesn't wrap, and it is not matched by a normal space in searches or regexes.

Is this enough to prevent XSS?

For text placed between tags, yes. Inside attributes, scripts, styles and URLs, other rules apply: use your framework's escaping instead of doing it by hand.

Is what I paste or test sent anywhere?

No. This page works entirely inside your browser, and pasted data never leaves your device. It makes no network requests while you use it, and the page also tells your browser to block them (a Content-Security-Policy with connect-src 'none'), so even a bug could not send your data out. To check it yourself, open your browser's developer tools, go to the Network tab, and use the tool: nothing will appear. There is no account, no analytics and no logging.