99digest is in early access — tools are free while we grow.
Guide

How to Encode and Decode HTML Entities

Show the text <b> on a web page and the browser tries to make something bold. To display it literally, you write it as an entity.

What the tool encodes

The HTML Entity Encoder/Decoder replaces the five characters that break HTML. The input <a href="x">Tom & Jerry's</a> becomes:

&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&#39;s&lt;/a&gt;

The five replacements are: & to &amp;, < to &lt;, > to &gt;, a double quote to &quot; and a single quote to &#39;.

What it decodes

Decoding turns those five entities back, and also converts numeric entities in decimal or hex form. &#169; becomes the copyright symbol. Other named entities, such as &copy; or &nbsp;, are left exactly as they are, because the tool does not carry a table of names. If you need those, replace them by hand or use the numeric form (&#169; for the copyright sign).

Using the tool

  1. Choose encode or decode.
  2. Paste your text.
  3. Copy the result.

When to encode

  • Showing code samples on a page.
  • Putting user-supplied text into an HTML attribute.
  • Writing an ampersand in an HTML or XML file.

Encoding is a basic safeguard but not complete security. Websites that accept user input must use the escaping built into their templating system, applied in the right place.

Frequently asked questions

Do I need to encode accented letters or emoji?

Not if the page is served as UTF-8, which is the norm. They can be written as they are.

Why did &amp;amp; appear?

Text that was already encoded was encoded a second time. Decode it once, then encode only the plain version.

Try the HTML Entity Encoder/Decoder Free, instant, and runs in your browser.