CruxDevCruxDev Tools Prompts
text Utility • Zero-Server Privacy • 100% Client-Side

HTML Entity Encoder & Decoder

Encode special characters to named or numeric HTML entities and decode encoded HTML entities back to raw text.

Overview

Encodes special characters into HTML entities in named, decimal or hex form, and decodes entity-laden text back into characters. Reserved characters like <, >, &, quotes and apostrophes, plus a small set of symbols such as copyright and trademark, are handled with a live preview of the result.

How It Works

Paste text or markup into the input. In encode mode, pick Named, Decimal or Hex and the converted text appears immediately — ampersands and angle brackets always become entities, and other characters in the tool's target range become the chosen numeric form. Switch to decode mode and any entities in the input are parsed back into their characters using the browser's own HTML parser, so the full set of HTML5 named entities is understood on the way in, even though encoding emits only a limited set.

Step-by-Step Usage Guide

  1. Paste the text or markup to convert into the input box.
  2. For encoding, choose Named (readable, twelve common symbols), Decimal (widest compatibility) or Hex (uppercase hex code points).
  3. For decoding, switch to decode mode; browser-level parsing understands every HTML5 named entity.
  4. Copy the result from the output panel.

Technical Specifications & Standards

Encoding is deliberately conservative: only characters in the range U+00A0 to U+9999 plus the five XML-reserved characters (& < > " ') are touched; ordinary ASCII letters and digits pass through untouched, keeping output compact and readable. Named mode maps twelve common characters to their canonical entities (&amp;, &lt;, &gt;, &quot;, &apos;, &copy;, &reg;, &trade;, &euro;, &pound;, &bull;, &mdash;) and falls back to decimal for everything else it targets; decimal and hex modes emit numeric references directly. Decode takes a different route: the input is parsed with DOMParser as an HTML document and read back as text, which means all 2,231 HTML5 named character references decode correctly because that table is built into the browser. One real edge case: encoding walks UTF-16 code units, so an emoji is emitted as two consecutive numeric references for its surrogate halves — browsers render the pair correctly, but a strict XML parser would reject the lone surrogates, so re-encode emoji output only in an HTML context.

Targeted Use Cases

  • Preparing text containing <, > and & for safe inclusion in HTML source or a CMS field.
  • Converting symbols like copyright and trademark into their typographic entity forms for legal or marketing copy.
  • Decoding a blob of entities from an API response, email source or scraped page back into readable text.
  • Producing numeric escapes for characters that break a templating or email pipeline.

Notes & Gotchas

  • Remember ampersands first: any URL or text containing & needs &amp; inside HTML attributes and content.
  • Prefer named entities for the common symbols in human-facing copy, numeric forms when targeting old or strict parsers.
  • Decode untrusted-looking entities rather than trusting them — DOMParser returns plain text, not executed markup.
  • Remember ASCII letters are never encoded; entities are for reserved and non-ASCII characters only.

Frequently Asked Questions

What is the difference between named and numeric entities?

Named entities are memorable words like &copy; for the copyright sign; numeric entities give the code point directly, as &#169; (decimal) or &#xA9; (hex). Browsers understand both; named form only exists for the characters the HTML spec has named.

Why are my letters not being encoded?

The encoder deliberately targets only the reserved five (& < > " ') and characters from U+00A0 upward. Plain ASCII text needs no entities in HTML and encoding it would just bloat the output.

How does decoding handle entities the encoder never produces?

Decoding parses the input with the browser's HTML parser, which implements the full HTML5 table of 2,231 named references. So &nbsp;, &mdash; and every other standard entity decode correctly even though this tool's encoder emits only a subset.

What happens to emoji?

Encoding walks UTF-16 code units, so an emoji becomes two consecutive numeric references for its surrogate halves. Browsers reassemble them when rendering the HTML, but a strict XML parser would object, so keep emoji output in HTML contexts.