HTML Entity Encoder & Decoder

Type in either box to turn text into HTML entities, or decode < & 中 and other entities back into text. All named entities supported.

How to Use

  1. Type or paste text into the top box and the HTML entities appear in the bottom box. By default only the five characters that mean something in HTML, < > & " and ', are converted. Everything else is left as it is.
  2. To put text into a system that only handles ASCII, tick “Also encode non-ASCII characters”: CJK, accents, and emoji become hex numeric entities such as &#x4E2D;, with one entity per emoji.
  3. Paste entities into the bottom box to decode them in the top box. There's no encode or decode button to pick. Named (&copy;), decimal (&#169;), and hex (&#xA9;) entities all work, and names are case-sensitive just like in the standard.
  4. If something is wrong, the box with the problem shows which character it is and why, and the other box keeps its last good result. “Select the problem” highlights that part for you.
  5. A lone & isn't treated as an entity, so AT&T, R&D, and &lang=en in a URL stay as they are. Only text written like &name; or &#number; gets checked.
  6. “Swap” moves the result into the box you typed in. “Clear” empties both boxes.

FAQ

What are HTML entities and why use them?

An HTML entity is a way to write one character as text that starts with & and ends with ;, for example &lt; for <, &amp; for &, and &copy; for ©. Since < and & have special meaning in HTML, you must write them as entities to show them as plain text on a page, otherwise the browser treats them as the start of a tag or entity. Converting user-provided text to entities before putting it in a page is also one of the basic defenses against XSS.

Are HTML entities a form of encryption?

No. HTML entities are an encoding: a public rule that rewrites characters, with no key, so anyone can turn them back into the original text. They hide nothing. To protect content, use real encryption.

What's the difference between named, decimal, and hex entities?

All three point at the same character: &copy;, &#169;, and &#xA9; are all ©. Named entities are easy to read, but only about two thousand characters listed in the HTML standard have a name. Numeric entities can express any Unicode character, and the hex number is the familiar U+ code point. This tool writes hex when encoding and understands all three when decoding.

Why is the single quote encoded as &#39; instead of &apos;?

&apos; exists in XML and HTML5, but HTML 4 and some older systems don't know it and show it as literal text. &#39; works everywhere, so it's the default. When decoding, both forms are understood.

What does it mean when decoding says an entity is “incomplete” or “not a standard name”?

The part starting with & looks like an entity but is written wrong. Typical causes are a missing closing ; (&amp or &#65), nothing after &#, or a misspelled or wrongly capitalized name (named entities are case-sensitive, so &Aacute; and &aacute; are different letters). A number can't be 0, above 10FFFF (hex), or between D800 and DFFF. The message points at the position, and once it's fixed the other box updates.