decoder.tools

HTML Entity Decoder

Turn HTML entities like &, < and € back into plain characters.

INPUT
OUTPUT

The result appears here as you type.

Decoding runs in your browser. What you paste is not sent to a server.

An HTML entity decoder replaces character references such as &, – and € with the characters they represent, giving you the original text or markup.

Example

Input
<p class="note">Fish & chips – €5</p>
Output
<p class="note">Fish & chips – €5</p>

What are HTML entities?

In HTML, <, > and & have special meaning, so to show them as text they have to be escaped. HTML offers three ways to write any character:

  • Named entities, such as &lt;, &gt;, &amp;, &quot; and &nbsp;.
  • Decimal references, such as &#8211;, which is Unicode code point 8211 (an en dash).
  • Hex references, such as &#x20AC;, which is code point U+20AC (the euro sign).

You usually need to decode entities when text has been escaped once too often. A classic case is &amp;amp;, which shows on screen as &amp;. It also comes up with RSS feeds, JSON APIs that return HTML-escaped strings, scraped pages and database fields that stored escaped markup.

This decoder resolves all numeric references, plus the common named entities (&amp; &lt; &gt; &quot; &apos; &nbsp; &copy; &reg; &trade; &hellip; &mdash; &ndash; &euro; &pound; and similar). Rarer named entities are left as they are.

How to use the HTML entity decoder

  1. Paste the escaped text or markup.
  2. Read the decoded result.
  3. If you still see entities such as &amp;lt;, the text was escaped twice. Paste the output back in and decode it again.

Decode HTML entities in code

Python
import html

print(html.unescape("Fish &amp; chips &#8211; &#x20AC;5"))  # Fish & chips – €5
JavaScript (browser)
// skip-run (needs a browser DOM)
const t = document.createElement("textarea");
t.innerHTML = "Fish &amp; chips &#8211; &#x20AC;5";
console.log(t.value); // Fish & chips – €5

HTML entities at a glance

SpecificationWHATWG HTML, named character references
Named form&name;, for example &amp;
Decimal form&#NNNN;, for example &#8211;
Hex form&#xHHHH;, for example &#x20AC;
Must always be escaped& and <, plus " inside attribute values

Frequently asked questions

Why does my page show &amp;?

The text was escaped twice: once when it was stored and again when it was printed. Decode it once to get &amp; and a second time to get &. The real fix is to escape only once, at output time.

Is decoding entities safe?

Decoding turns &lt;script&gt; into a real <script> tag. That is fine for reading, but never insert decoded text into a web page without escaping it again, or you open the page to cross-site scripting (XSS).

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

&nbsp; (U+00A0) is a non-breaking space. It looks like a space but stops the browser from wrapping a line at that point, and it isn't collapsed with neighbouring spaces.

Last reviewed · found a mistake? contact@decoder.tools · view as markdown