Skip to content

HTML Entity Encoder / Decoder

Escape text for safe use in HTML, or decode entities such as &, © and 😀 back into readable characters. Choose named or numeric references, or escape only the five characters that break markup. The conversion runs in your browser.

Runs in your browserFreeNo sign-up

Processed on your device. Files and text stay in your browser and are not uploaded to our servers. How privacy works

How to use the html entity encoder / decoder

  1. Choose Encode to turn text or HTML source into entities, or Decode to turn entities back into characters. Pasting text with entities switches to Decode automatically.
  2. For encoding, decide whether to escape only & < > " ' (ideal for templating) or every non-ASCII character too, and whether numeric references should be decimal or hexadecimal.
  3. Copy or download the result, or press Swap to convert it back the other way.

Features

  • Named entities from the full HTML 4 set (Latin-1, Greek, arrows, maths, punctuation) with numeric fallback
  • Minimal mode that escapes only the characters that can break HTML or enable XSS
  • Decodes named, decimal and hexadecimal references, including emoji and legacy references without semicolons
  • Browser-accurate handling of edge cases such as &#150; and invalid code points
  • Auto-detects whether pasted text should be encoded or decoded

When to escape and what to escape

In HTML, & starts an entity and < starts a tag, so user-provided text placed into a page must have those characters escaped, plus " and ' when the text goes inside an attribute value. Escaping only those five characters is enough for security and keeps the source readable, which is why templating engines do exactly that. Encoding every accented or non-Latin character is only needed for documents that are not served as UTF-8, which is rare today.

Named versus numeric references

&copy; and &#169; and &#xA9; all produce ©. Named references are readable but only about 250 of them exist in HTML 4 (HTML5 defines more than 2,000, but browsers are the only place all of them are recognised). Numeric references work for every Unicode character, including emoji, and are the safe choice in XML, SVG and email templates where named entities beyond the basic five may not be defined.

Decoding quirks browsers apply

Browsers accept a few legacy names without a trailing semicolon (&amp, &lt, &copy) and this decoder does too. Numeric references &#128; to &#159; are remapped to Windows-1252 characters, so &#150; becomes an en dash rather than a control character. References to 0, surrogates or values above U+10FFFF become the replacement character.

Frequently asked questions

Is this the same as URL encoding?

No. HTML entities protect text inside HTML markup, while percent-encoding protects text inside URLs. A value that appears in a link's href may need both, applied in the right order.

Why is my apostrophe encoded as &#39; rather than &apos;?

&apos; is not defined in HTML 4 and older Internet Explorer versions didn't understand it. &#39; works everywhere, so it is the conventional choice.

Can I decode text copied from a web page or an RSS feed?

Yes. Paste it and the tool switches to Decode when it sees entity references, turning &amp;, &nbsp;, &rsquo; and numeric codes into normal characters.

Is my text sent anywhere?

No. Encoding and decoding are done in your browser with a built-in table; nothing is uploaded.

Other tools people use alongside HTML Entity Encoder / Decoder.

You might also like

Something useful from another corner of VoltKit.