HTML Entities Encoder and Decoder

Escape &, <, >, quotes and apostrophes as HTML entities so they show as text, or decode entities like &amp; and &#169; back to characters. Free.

In HTML, a few characters are reserved. A < starts a tag, an & starts an entity, and a quote ends an attribute value. If you want the browser to show one of these as plain text, such as a code sample, a maths expression or a company name like “AT&T”, you write it as an entity: &lt;, &amp;, &quot;. This tool converts in both directions.

Encoding

Choose Encode and paste your text. Five characters are replaced: the ampersand with &amp;, less-than with &lt;, greater-than with &gt;, a double quote with &quot; and an apostrophe with &#39;. Everything else, including accented letters and emoji, is left as it is, which is the modern way: pages are served as UTF-8 and have no need to turn “é” into &eacute;.

<p class="note">Tom & Jerry's "show"</p>

becomes

&lt;p class=&quot;note&quot;&gt;Tom &amp; Jerry&#39;s &quot;show&quot;&lt;/p&gt;

That is exactly what you put into a page, or into the content of a <pre> block, when you want the browser to display the original line rather than act on it.

Encoding matters for security as well as display. Putting user-supplied text into a page without escaping it is how cross-site scripting happens, because a visitor can type a script tag and have it run. Any code that builds HTML from untrusted text should escape it, and it is best done by your framework’s own functions, not by hand. This tool is for the occasional manual job.

Decoding

Choose Decode to turn entities back into characters. Two kinds are handled: numeric entities, in decimal (&#169;) or hex (&#xA9;), which cover any character at all, and a small set of named ones: &amp;, &lt;, &gt;, &quot;, &apos; and &nbsp;.

That last point deserves honesty. HTML defines more than two thousand named entities, such as &copy;, &eacute; and &hellip;. This tool decodes only the six above and numeric ones, and leaves the others as they are. If you have text with many named entities, decode it through a browser, or replace them with their numeric forms first. For a page’s worth of HTML where you only want readable text, remove HTML tags does the tag stripping and the same entity decoding in one go.

Common questions about entities

An &nbsp; is a non-breaking space; it looks like a space but stops the line breaking there, and it is often the culprit when text refuses to wrap or a space cannot be found. After decoding, it appears as an ordinary space. If you need to see what a character is, the text to Unicode converter gives you its code point, which is also the number in a numeric entity.

For other encodings, see URL encoding and Base64.

Frequently asked questions

Which characters must be escaped in HTML?

The ampersand and the less-than sign always, since they start entities and tags. Quotes need escaping inside attribute values. The greater-than sign is safe in most text but is escaped for consistency.

Why was &copy; not decoded?

This tool decodes numeric entities and the six most common named ones only. Other named entities are left unchanged. Replace them with numeric forms, such as &#169; for the copyright sign, or decode them in a browser.

Do I need to encode accented letters?

Not on a modern page served as UTF-8. Letters like é can sit in the HTML directly, and only the reserved characters need escaping.