piapia123
en

HTML Entity Encode & Decode

Encoding & Crypto

Everything runs locally in your browser — nothing is uploaded

Input
Output

Turn < > & " and the single quote into entities, or turn entities back into characters. Encoding touches only those five, which are the ones with real syntactic meaning in HTML: they decide where a tag starts and where an attribute value ends. Every other character is perfectly valid as a literal, and escaping all of them just makes the output unreadable and impossible to diff. Decoding understands named entities (the 200+ that actually show up in web pages) plus decimal references like &#20013; and hexadecimal ones like &#x4E2D;, and it runs exactly one pass: &amp;lt; becomes &lt;, never <, because repeated decoding is the classic way XSS gets through. Unknown entities are passed through untouched rather than thrown away.

Features

  • Both directions: text ⇄ HTML entities
  • Escapes only the five syntax-significant characters, leaving the rest readable
  • Optional numeric escaping of non-ASCII characters, including emoji
  • Decodes 200+ named entities: nbsp, copy, mdash, arrows, maths symbols, Greek letters
  • Decodes both decimal &#20013; and hexadecimal &#x4E2D; numeric references
  • Single-pass decoding, so &amp;lt; yields &lt; rather than <
  • Unknown entities and out-of-range code points are passed through untouched

How to use

  1. Pick the direction: encode or decode
  2. Tick "escape non-ASCII" if you need the whole text ASCII-only
  3. Paste your content — the result appears instantly
  4. Click Copy to take the result

FAQ

Why only five characters?
Because in HTML only < > & " and the single quote carry syntax: they mark where a tag begins, where an attribute value ends and where an entity starts. Everything else, including CJK text and emoji, is valid as a literal, and escaping all of it only makes the markup hard to read. If you do need ASCII-only output, tick the non-ASCII option.
Why is the single quote &#39; and not &apos;?
&apos; only arrived with XML and HTML5, and older parsers do not know it. The numeric reference &#39; is equivalent to a single quote everywhere, which makes it the safer choice.
Why does &amp;lt; decode to &lt; and not to a literal angle bracket?
The decoder runs a single pass, which is the safe behaviour. Decoding repeatedly is what lets input like &amp;lt;script&amp;gt; slip past a filter that only cleans once — the classic route to XSS. If you really need a second pass, run the result through again deliberately.
Why are some entities left alone?
This tool covers the 200+ entities that appear in real web pages rather than the full HTML5 list of 2200+, which would multiply the page size. Anything outside the table, such as &foo;, is kept exactly as written — you can see that it was not handled instead of getting an error or silently losing it.

Related tools