An HTML entity decoder replaces character references such as &, – and € with the characters they represent, giving you the original text or markup.
Example
<p class="note">Fish & chips – €5</p><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
<,>,&,"and . - Decimal references, such as
–, which is Unicode code point 8211 (an en dash). - Hex references, such as
€, 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;, which shows on screen as &. 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 (& < > " ' © ® ™ … — – € £ and similar). Rarer named entities are left as they are.
How to use the HTML entity decoder
- Paste the escaped text or markup.
- Read the decoded result.
- If you still see entities such as
&lt;, the text was escaped twice. Paste the output back in and decode it again.
Decode HTML entities in code
import html
print(html.unescape("Fish & chips – €5")) # Fish & chips – €5// skip-run (needs a browser DOM)
const t = document.createElement("textarea");
t.innerHTML = "Fish & chips – €5";
console.log(t.value); // Fish & chips – €5HTML entities at a glance
| Specification | WHATWG HTML, named character references |
| Named form | &name;, for example & |
| Decimal form | &#NNNN;, for example – |
| Hex form | &#xHHHH;, for example € |
| Must always be escaped | & and <, plus " inside attribute values |
Frequently asked questions
Why does my page show &?
The text was escaped twice: once when it was stored and again when it was printed. Decode it once to get & and a second time to get &. The real fix is to escape only once, at output time.
Is decoding entities safe?
Decoding turns <script> 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 and a normal space?
(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