Why encode HTML entities?

A few characters have a job in HTML: < and > mark tags, & starts an entity, and quotes close attribute values. To show them as plain characters, a page writes them as entities, short codes that start with & and end with ;, such as &lt; for <. You need this to show HTML code in a blog post or a tutorial, or to put quotes inside an attribute value.

Tool description

Type or paste text or HTML into the first editor, and the encoded text appears in the second one as you type, ready to copy. The tool encodes the five characters that have a meaning in HTML:

Character Entity
< &lt;
> &gt;
& &amp;
" &quot;
' &apos;

Everything else stays as it is, including accented letters, symbols such as © and €, and emoji, as pages saved as UTF-8 show them directly. Insert sample fills in <p>Hello World</p>, which becomes &lt;p&gt;Hello World&lt;/p&gt;.

To turn entities back into characters, press the swap button between the editors, which also moves the result into the input, or use the HTML Entities Decoder.

Features

  • Encodes as you type
  • Encodes only what HTML needs, so the rest of the text stays readable
  • Runs in your browser

Examples

  • <b>Bakery</b> becomes &lt;b&gt;Bakery&lt;/b&gt;
  • Fish & chips becomes Fish &amp; chips
  • <a title="Tea & cake">Menu</a> becomes &lt;a title=&quot;Tea &amp; cake&quot;&gt;Menu&lt;/a&gt;
  • Let's bake becomes Let&apos;s bake
  • Crème brûlée 🧁 stays as it is

Good to know

  • Encode text only once. An entity starts with &, which gets encoded too, so &lt; becomes &amp;lt; and shows on the page as &lt; instead of <.
  • These five entities are also the five that XML defines, so the result works in XML files too.
  • &apos; is the apostrophe's name in HTML5 and XML. Some code writes it as &#39;, which means the same.