Yueseryueser.com

← All guides

HTML Entity Decoder Guide: Turning & Back into &

APIs return escaped quotes, emails are full of apostrophe entities, template variables print line-break tags. Decoding is fast; deciding whether this is the right layer to decode at is the hard part.

Open the tool:HTML Entity Decoder

Where the entities come from

Double escaping is the classic cause: content is escaped once before storage and again on output, so the page shows <. Email and RSS are the other common source, because their HTML handling is more conservative and often keeps entities intact.

Scraped API data hits it too: a JSON string keeps " in place, which makes the payload hard to read. Restoring the quote is usually the first step to telling whether the value is JSON, HTML, or just text.

Decoding happens one layer at a time

The tool parses once as HTML: &amp; becomes &, &lt; becomes <, &#39; and &#x27; become a single quote, and &nbsp; becomes a non-breaking space. If the source was &amp;lt;, you get &lt;, not <, because that was escaped twice.

Output is displayed as text and is not executed, so a restored script tag does not run. That can lull you into pasting the result back into a page, where, once it reaches innerHTML, it becomes a real tag again.

Boundary: re-decide after decoding

Decoding is not sanitising. Once an entity becomes an angle bracket, the text has HTML meaning again. If it came from a user, it must be escaped for its output context before it goes back on a page, or you have reopened the injection hole yourself.

It also does not handle JavaScript unicode escapes, URL percent-encoding, or JSON escapes, which follow their own rules. Hexadecimal numeric entities such as &#x1F600; decode fine, though characters above the BMP can still render inconsistently in old environments.

FAQ

Why does &amp;lt; only decode halfway?

It was escaped twice. The first pass turns &amp; into &, leaving lt; as ordinary text. A second pass produces the angle bracket. Seeing this usually means some stage is escaping twice, which is worth fixing at the source.

Can I paste the result into a page?

Not directly. Decoding returns raw characters, including angle brackets, which have syntactic meaning. Re-escape for the output context before inserting, or the text becomes markup.

What does &nbsp; decode to?

A non-breaking space (U+00A0). It looks like a normal space but is not collapsed by the browser and does not break across lines. Pasted into code, it causes strings that look identical but are not.

Related tool:HTML Entity Decoder