HTML entity encoder / decoder

Turn & < > into safe HTML, or decode named, decimal and hexadecimal entities back into readable text — including emoji.

How to use

  • Type on the left and press Encode to escape the five HTML-critical characters: &, <, >, ", '.
  • Paste anything with entities on the right and press Decode — named forms (&copy;), decimal (&#169;) and hex (&#xA9;) all resolve, and unsupported names fail loudly instead of passing through.
  • With Encode all non-ASCII checked, every character above U+007F becomes a numeric entity — useful for legacy systems or mail templates that mishandle UTF-8.

When to escape what

  • Text content: escaping & and < is mandatory; the quotes are harmless extra.
  • Inside attribute values: escape the quotes too, or a " in user data can break out of the attribute — that is how attribute-injection XSS starts.
  • Inside <script> or JSON embedded in HTML: entities do not protect you there; escape the </script> closing sequence instead.

The classic bug: double-escaping

If a page literally shows &amp; where an ampersand should be, the text was escaped twice — once by the CMS, once by the template. The fix is to escape at one layer only, ideally the one closest to output. This decoder helps you inspect what a suspicious string actually contains: paste it, decode, and see whether the entities are one or two layers deep.

FAQ

What is the difference between &nbsp; and a regular space?

&nbsp; is a non-breaking space (U+00A0): line breaking will not split there, and HTML collapses are not applied to it. A trailing &nbsp; in a textarea value is also a common reason "identical" strings fail comparisons — decode before diffing.

Can I encode a whole HTML document with this?

You can, but that produces display text — the tags will render as literal <div> on the page. That is exactly right for showing code examples, and exactly wrong if you wanted the browser to render the markup.

Why does decoding fail on some names like &frasdf;?

Because they are not real entity names — browsers silently render unknown entities literally, which masks typos in hand-written HTML. This tool treats them as errors so broken markup is caught before publishing.

Other tools