DevTools Hub

HTML Encoder / Decoder

Encode and decode HTML entities.

Runs locally
InputPlain text
42 chars
OutputHTML entities
Ready
The output will appear here.
Status
HTML entities processed locally.

How it works

HTML entities let a document contain characters that would otherwise be parsed as markup. Encoding turns & < > " and ' into &amp; &lt; &gt; &quot; and &#39;, which is what stops user-supplied text from being read as tags. Encode all goes further and also turns every non-ASCII character into a numeric entity, so é becomes &#233;, for email templates and legacy systems that mangle UTF-8.

Decoding uses the browser's own HTML parser, so it understands all 2,000+ named entities in the HTML5 specification, from &copy; and &eacute; to &rarr; and &hellip;, plus any numeric reference: decimal such as &#8364; or hexadecimal such as &#x20AC;, both of which produce the euro sign. The result is exactly what a browser would render.

A named entity the decoder does not recognise is left exactly as it was rather than dropped, and tags in the input stay as plain text, so nothing is silently lost or executed.

Frequently asked questions

Which characters does HTML encoding escape?
The five that matter for markup safety: ampersand, less-than, greater-than, double quote, and apostrophe. In Encode mode everything else, accented letters and emoji included, is left alone, because modern pages are UTF-8 and do not need those escaped. Encode all escapes every non-ASCII character too.
What is &nbsp;?
A non-breaking space, U+00A0. It looks like an ordinary space but prevents a line break at that point, which is why it turns up throughout content copied out of word processors and CMS editors.
Does it decode named entities such as &copy; or &mdash;?
Yes, every named entity in the HTML5 specification: &copy; produces the copyright sign and &mdash; an em dash, as do their numeric forms &#169; and &#8212;. Any unrecognised named entity is returned unchanged.
Is HTML encoding the same as URL encoding?
No. HTML entities protect characters inside a document's markup, while percent-encoding such as %20 or %3A protects characters inside a URL. Text pulled out of an HTML page can need both, applied in order.