HTML Entity Encoder / Decoder

Escape text for HTML — < > & and quotes — or turn entities like &eacute; and &#x1F600; back into characters. Choose how much to escape and see every replacement.

Encoder Text & Encoding Updated Oct 2, 2026
How to Use
  1. Choose Encode (text → HTML-safe text) or Decode (entities → characters).
  2. When encoding, pick how much to escape: just what HTML needs in text, also quotes for attributes, or every non-English character as well.
  3. Type or paste into the input box. The result updates as you type.
  4. Check the replacement table and Show Work to see exactly which characters changed and why.
  5. Press Copy for the result, or Swap to send it back the other way.
Input
plain text
Presets
Result
Chars in
—
Chars out
—
Entities
—
Size change
—

Worked Example

Show the code <p>Fish & Chips</p> as text on a page.

< becomes &lt;, > becomes &gt; and & becomes &amp;.
Result: &lt;p&gt;Fish &amp; Chips&lt;/p&gt; — 19 characters became 35, and the browser now shows the tags instead of making a paragraph.

“é” is code point U+00E9 = 233. It can be written &eacute; (named), &#233; (decimal) or &#xE9; (hex); all three display as é. Escape the & first when doing it by hand, or &lt; turns into &amp;lt;.

Show Work

Type something above to see each replacement.

Formulas

Named
&name;
&amp; &lt; &eacute; &nbsp; &mdash;
Decimal
&#N;
N = code point in decimal: &#233;
Hex
&#xH;
H = code point in hex: &#xE9; &#x1F600;
Text content
& → &amp;   < → &lt;
> → &gt; by convention
Attributes
" → &quot;   ' → &#39;
Plus everything for text content
Order
& first
Otherwise &lt; becomes &amp;lt;

Where HTML Entities Came From

HTML inherited character references from SGML. Because < starts a tag and & starts a reference, those characters needed another way to be written, and early pages also needed a way to show accented letters on systems limited to plain ASCII. HTML 2.0 (1995) named the Latin-1 letters such as &eacute;, and HTML 4 (1997) brought the list to 252 names, adding Greek letters, mathematical symbols and typographic marks like &mdash; and &euro;.

HTML5 defines 2,231 named character references, many of them for mathematics. With pages now saved as UTF-8, characters like é and — can simply be typed, so escaping is mainly about the few characters that have meaning in HTML itself.

About This Tool

This tool escapes text for HTML at four levels — just what text content needs, what attribute values need, or every non-ASCII character as well, as numbers or by name — and decodes any named or numeric entity back to its character.

Decoding is done in a single pass, the way a browser reads a page, so &amp;lt; correctly becomes the text &lt; rather than a <. It recognises all HTML5 entity names, never runs any markup you paste, and points out text that looks escaped twice. Everything runs in your browser.

Related tools: URL Encoder / Decoder, Base64 Encoder / Decoder, and Unicode Lab.

Frequently Asked Questions

Which characters must be escaped in HTML?

In normal text, & and < must be written as &amp; and &lt; (and > as &gt; by convention). Inside an attribute value in double quotes, " must also be escaped as &quot;, and inside single quotes, ' as &#39;. Everything else can be typed as it is in a UTF-8 page.

What is the difference between &eacute;, &#233; and &#xE9;?

All three mean “é”. &eacute; is a named entity, &#233; is the decimal code point and &#xE9; is the same number in hex. Named entities exist only for some characters; numeric ones work for every character, including emoji such as &#x1F600; (😀).

Why do I see &amp; on a page instead of &?

The text was escaped twice. Escaping once turns & into &amp;; escaping again turns that into &amp;amp;, which the browser shows as &amp;. Decode once to fix it, and escape only at the moment text is put into HTML — not when it is stored.

Does escaping HTML prevent XSS?

It prevents it in the places this tool is for: text between tags and quoted attribute values. It is not enough inside a <script> block, a style attribute or a URL such as href="javascript:…", which need their own rules. Escape for the exact context the text goes into.

Is &apos; valid?

In HTML5 and XML, yes. It was not part of HTML 4, so &#39; is the safer choice when the page might be read by old software, and it is what this tool uses.

How do I use the HTML Entity Encoder / Decoder?

Simply type or paste your value and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Do I need to install or sign up for anything?

Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.

Is my information private?

Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.

Common Use Cases

Showing code on a web page

To display <div class="box"> as text in a tutorial, it must be written &lt;div class=&quot;box&quot;&gt;, or the browser makes a real div.

Fixing double-escaped text

A CMS that shows “Fish &amp; Chips” has escaped twice. Decode once to get back to Fish & Chips.

Emails and old systems

When a template or database cannot store UTF-8, “Crème brûlée” can travel as Cr&#232;me br&#251;l&#233;e and still display correctly.

Reading scraped HTML

Text copied from page source is full of &rsquo;, &mdash; and &nbsp;. Decode it to get clean, readable text.

Safe attribute values

A title like Tom's "best" car must be escaped as Tom&#39;s &quot;best&quot; car before it goes inside title="…".

Last updated: