Encoding & Escaping beginner 8 min

Decode HTML Entities From a Scraped Snippet

Decode entity-heavy text so copied content can be reviewed without losing the original meaning.

Scenario

A scraper returned Tom & Jerry <span>Sale Now</span> where the page showed "Tom & Jerry" and a styled sale banner. The content was HTML-escaped somewhere in the pipeline — every & became &, angle brackets became </>, and an invisible   is hiding where a space should be. Before judging whether the scrape is correct, decode the entities so you are comparing text with text.

Broken input

Tom & Jerry <span>Sale Now</span>

Goal

Use HTML Entity Encoder / Decoder to turn the entities back into readable characters and reveal what the scraper actually captured — including whether those <span> tags are markup or escaped literal text.

Tool sequence

  1. Open HTML Entity Encoder / Decoder.
  2. Paste the scraped string and decode it once.
  3. Read the result: Tom & Jerry <span>Sale Now</span> — the tags were escaped text in the source, meaning the scraper captured markup as content.
  4. Watch the &nbsp;: it decodes to a non-breaking space (U+00A0) that looks like a normal space but fails string comparisons; check it with ASCII / Unicode Explorer if downstream matching misbehaves.
  5. Decide the fix at the pipeline level — either the scraper should unescape entities, or it should extract text content instead of inner HTML; re-scrape and confirm.

Checkpoint output

Tom &amp; Jerry &lt;span&gt;Sale&nbsp;Now&lt;/span&gt;
→ Tom & Jerry <span>Sale Now</span>
              └── literal tag text, and "Sale Now" hides a U+00A0

One decode pass restores the ampersand, exposes the escaped <span> tags, and reveals the non-breaking space — three separate data issues from one glance.

Common mistakes

  • Decoding entities and then injecting the result as trusted HTML — decoded <span> from scraped content is an XSS vector if rendered.
  • Missing non-breaking spaces because they render exactly like regular spaces until an equality check fails.
  • Encoding already-encoded text a second time, producing &amp;amp; chains that need multiple decode passes.
  • Decoding in a loop "until it stops changing," which corrupts legitimate text that mentions entities.

Related tools and lessons