HTML entities encoder and decoder

Turn special characters into safe HTML entities, or decode named and numeric entities back to readable text. Your text stays in your browser.

How to use it

  1. Paste your text or HTML in the box.
  2. Choose Encode to HTML entities or Decode HTML entities in Operation.
  3. When encoding, use When encoding to escape only the essentials or all non-ASCII characters.
  4. Click Copy to use the result.

Complete guide to HTML entities

What HTML entities are

Some characters have a special meaning in HTML. The less-than sign starts a tag, the ampersand starts an entity, and quotes close attribute values. To show them as plain text, or to put text safely inside markup, you write them as entities: a code that starts with & and ends with ;. This tool converts in both directions, so you can escape text before pasting it into a page, an e-mail template or a CMS, or turn a block full of & and é back into readable text.

Three kinds of entity

  • Named, such as ©: easy to read, but only defined for known characters.
  • Decimal, such as ©: the Unicode number of the character.
  • Hexadecimal, such as ©: the same number in base 16.
CharacterNamed or common formDecimal
&&&
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&#39;&#39;
é&eacute;&#233;
€&euro;&#8364;

The four encoding options

When encoding, When encoding decides how far to go. The first five characters in the table are always escaped, because they can break markup. The option only controls what happens to everything outside basic ASCII.

  • Only the essential characters: escapes the five and leaves accents and symbols readable. The best choice for pages served as UTF-8.
  • Essential + non-ASCII as named entities: uses names such as &eacute; when one exists and decimal numbers otherwise.
  • Essential + all non-ASCII as decimal and as hex: every character above ASCII becomes a number, useful for systems that cannot handle UTF-8.

Worked example

  1. Paste <p class="x">Café & crème - 5 € © 2025</p> in Your text or HTML and leave Operation on Encode to HTML entities.
  2. With Only the essential characters the Result is &lt;p class=&quot;x&quot;&gt;Café &amp; crème - 5 € © 2025&lt;/p&gt;. The tag is now harmless text, and "é", "€" and "©" are untouched.
  3. With the named option you get &lt;p class=&quot;x&quot;&gt;Caf&eacute; &amp; cr&egrave;me - 5 &euro; &copy; 2025&lt;/p&gt;.
  4. The decimal option gives &lt;p class=&quot;x&quot;&gt;Caf&#233; &amp; cr&#232;me - 5 &#8364; &#169; 2025&lt;/p&gt;, and the hex option &lt;p class=&quot;x&quot;&gt;Caf&#xE9; &amp; cr&#xE8;me - 5 &#x20AC; &#xA9; 2025&lt;/p&gt;.
  5. To go back, choose Decode HTML entities and paste &lt;b&gt;Caf&eacute; &amp; &#233; &#xE9; &euro; &foo;. The result is <b>Café & é é € &foo;. Named, decimal and hex forms all decode, and the unknown name &foo; is left as it was.

Tips and common mistakes

  • Do not encode twice. Encoding text that already contains entities turns &amp; into &amp;amp;, and the page shows the code instead of the character.
  • Decoding is done in one pass, so &amp;lt; becomes &lt;, not <.
  • The no-break space &nbsp; decodes to a real non-breaking space, which looks like a normal space but is a different character.
  • Escaping helps display user text safely, but real applications should rely on their template engine or framework to escape output automatically.

Related tools

For quotes and backslashes in code strings use the string escape tool. For web addresses use the URL encoder and decoder, and to tidy the markup itself use the HTML beautifier.

Questions

Which characters must be escaped in HTML?

At minimum & and <, plus > and quotes inside attribute values. The "essential" option escapes & < > " and ' and leaves everything else readable.

When should I escape non-ASCII characters?

Only if your page or system is not served as UTF-8. With UTF-8, accented letters and symbols work as they are, so the essential option is enough.

Which named entities can be decoded?

The common ones: the basic five, the full Latin-1 set (nbsp, copy, eacute and so on), typographic quotes and dashes, arrows, the euro sign and a few Greek letters. Any numeric entity, decimal or hex, is decoded. Unknown names are left unchanged.

Does it help against XSS?

Escaping user input before putting it in HTML is a core defense, but real applications should rely on their template engine or framework to do it automatically.