toolqik

81 · Encode & Convert

HTML Entity Encoder & Decoder

Encode text to HTML entities like < and é, or decode entities back to text.

Runs in your browser
Mode
Encode
Non-ASCII as
Options
Result

  

About this tool

HTML uses <, > and & for markup, so to show those characters as text you write them as entities: &lt;, &gt; and &amp;. This tool encodes text into entities and decodes entities back to text. It is also called HTML escaping and unescaping.

Encoding

  • Only & < > " ' (default) is what you need to put user text safely into HTML: it prevents the text from being read as tags, which is the core of preventing XSS (cross-site scripting).
  • Also non-ASCII turns characters like é, € and ✓ into entities too, as named entities where one exists (&eacute;, &euro;), or decimal/hex numeric references (&#233;, &#xE9;). Useful for email templates and systems that mangle UTF-8.

Decoding

Decoding uses your browser’s own HTML parser, so every one of the 2,231 named entities in the HTML standard works (&check;, &NotEqualTilde;, &hearts;…), as do numeric references and entities without the final semicolon, exactly as a browser would read them.

Common entities

CharacterNamedNumeric
&&amp;&#38;
< >&lt; &gt;&#60; &#62;
" '&quot; &apos;&#34; &#39;
non-breaking space&nbsp;&#160;
© ® ™&copy; &reg; &trade;&#169; &#174; &#8482;
€ £ ¥&euro; &pound; &yen;&#8364; &#163; &#165;
— – …&mdash; &ndash; &hellip;&#8212; &#8211; &#8230;
“ ” ‘ ’&ldquo; &rdquo; &lsquo; &rsquo;&#8220; &#8221; &#8216; &#8217;

Encoding for HTML is not enough inside JavaScript, URLs or CSS, which each have their own escaping rules. Use the URL encoder for URLs and JSON escape for JavaScript strings.

FAQ

How do I encode HTML special characters?

Paste the text in Encode mode. &, <, >, " and ' are converted to &amp;, &lt;, &gt;, &quot; and &#39;, so the text displays literally instead of being read as HTML.

How do I decode HTML entities?

Switch to Decode and paste the text. Every named and numeric entity, such as &amp;, &eacute; or &#8364;, is converted back to its character.

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

&nbsp; is a non-breaking space (U+00A0): it looks like a space but stops a line break there, and browsers do not collapse several of them into one.

Does HTML encoding prevent XSS?

Encoding & < > " ' is the right defence for text placed between HTML tags or in quoted attributes. Text inside <script>, URLs, CSS or event handlers needs different escaping.

Do I need entities for accented letters?

Not if your page is UTF-8, which almost all are. Entities for non-ASCII characters are only needed for systems that cannot handle UTF-8.

esc
↑↓ navigate↵ open