Decode HTML Entities into Readable Text

How decoding HTML entities works, what it changes, and when the decoded text is safe to copy, share or reuse, including decoding web addresses and avoiding common mistakes.

HTML source often holds text you cannot read at a glance. You may see & where you expect an ampersand, © where you expect a copyright sign, or " around a quoted phrase. Decoding these entities turns them back into the characters they stand for. This review covers what decoding changes, when it fits your purpose, and where it can cause problems once the text leaves its original page.

Short answer: is decoding the right step for you?

Decoding is the right step if you want to read, quote, search or reuse the text as people see it on a rendered page. Typical cases include pulling text out of page source, cleaning scraped content, and recovering the real web address stored in a link attribute. The main benefit is that the output is ordinary Unicode text with no markup encoding in the way.

The key tradeoff is that decoding removes a layer of protection. Entities such as < and > often exist so that angle brackets show up as visible characters instead of being read as markup. If you decode text and then put it back into an HTML page, template or rich-text field without re-escaping it, characters that were harmless can become live tags. That can break the layout or create a script-injection risk.

  • Keep the encoded form, or re-encode after editing, when:
  • The text is going back into HTML source, an attribute value or a template.
  • The entities are deliberate, as in a tutorial that shows markup as visible code.
  • You need a byte-exact copy of the source for comparison, auditing or version control.
  • You do not yet know whether the content has been encoded once or more than once.

What decoding actually changes

An HTML entity, more precisely a character reference, is a short code that stands for one character. Decoding replaces each code with the character itself. That character is then stored in your text. This is a real change to the stored characters, not a visual effect. Copying the output copies the actual characters, not instructions for showing them.

Form | Example | Decodes to
Named reference | & | &
Named reference | © | ©
Decimal numeric reference | © | ©
Hexadecimal numeric reference | © | ©
Named reference for an invisible character |   | non-breaking space (U+00A0)

Here is a worked example. Every reference in the input maps to exactly one character in the output, and the plain words stay the same:

Input:  Fish & Chips — "fresh daily" © —
Output: Fish & Chips — "fresh daily" © —

Both — and — produce the same em dash (U+2014). Named, decimal and hexadecimal references are three ways of writing the same thing. Once decoded, nothing shows which form the source used. Decoding is a one-way normalization in that sense.

"HTML unicode to text": an ambiguous request

People who search for decoding "HTML unicode" may mean different encodings. Numeric references such as — are HTML and are handled by an entity decoder. Escapes such as \u2014, found in JavaScript and JSON, are a different syntax. Percent-encoding such as %E2%80%94, used in web addresses, is a third. An HTML entity decoder is not expected to handle the other two. If your input contains backslash or percent sequences, use a decoder built for that format.

Decoding web addresses taken from HTML

In HTML source, ampersands inside link attributes are often written as &. To recover the address a browser would actually follow, decode the attribute value:

In source:   ?q=green%20tea&sort=new
Decoded:     ?q=green%20tea&sort=new

The %20 is unchanged. Entity decoding fixes the HTML layer only, and the percent-encoding belongs to the address itself, so leaving it alone is correct. Decode the HTML layer once, and only decode percent-encoding as a separate step if you need the human-readable query values. Do not use the decoded form as the address.

Double encoding and edge cases

Content that has been escaped twice holds sequences like &amp;lt;. One decoding pass gives &lt;, and a second pass gives <. Decoding repeatedly until nothing changes may seem convenient, but it can also decode text that was meant to stay literal, such as an article explaining entities. Decode once, check the result, and repeat only if you know the source was double-encoded.

Tools also differ on malformed input. Examples include named references without a closing semicolon, names that do not exist, and numeric references to invalid code points. The HTML standard defines how browsers handle many of these cases. For instance, it maps some numeric references in the 128–159 range to Windows-1252 characters and replaces null or out-of-range references with the replacement character (U+FFFD). Not every standalone decoder follows those rules. If your input may be malformed, test a few samples in the tool you plan to use. No specific tool was tested for this review.

Will the decoded text stay readable after copying or sharing?

In most cases, decoded text is more portable than the encoded form. It holds ordinary Unicode characters, so pasting it into a document, message or spreadsheet carries those characters over directly. The encoded form only reads correctly inside software that interprets HTML. Elsewhere, people see literal strings such as &amp; or &#8217;.

Assistive technology benefits in the same way. A screen reader given decoded text meets a real ampersand or dash rather than a string of letters and punctuation. Decoded output is generally the better choice for anything people will read or hear. How a particular screen reader voices a given symbol varies by product and settings, and that was not tested here.

  • Limits to check before sharing:
  • Invisible characters: &nbsp;, &shy; (soft hyphen), &zwj;, &zwnj;, &lrm; and &rlm; decode to characters you cannot see. They can make two strings look identical but fail an exact match, interfere with search, or move the cursor unexpectedly while editing.
  • Direction marks: &lrm; and &rlm; change bidirectional display order. Removing or moving them can reorder mixed left-to-right and right-to-left text.
  • Font coverage: a decoded symbol only shows if the destination's font supports it. Otherwise readers may see an empty box or a placeholder.
  • Line breaking: a non-breaking space keeps neighboring words on the same line, which can affect layout in narrow fields.

If the destination is plain text, such as a search box, a database field or a message, the decoded version is usually what you want. You may also want to replace non-breaking spaces with regular spaces and remove other invisible characters. If the destination is HTML, re-escape the text, or use a method that inserts it as text rather than as markup.

Privacy and evidence gaps

This review is based on how HTML character references are defined to work, not on tests of a particular decoder. No measurements, product comparisons or data-handling details were available. A tool's look or wording does not show whether it processes input locally or sends it to a server. Before pasting sensitive content into an online decoder, check its stated privacy terms, or decode with software that runs on your own device.