Skip to content
M2TOOLKIT

Developer · free tool

HTML Entity Encoder & Decoder

Escape characters that have special meaning in HTML, or turn entities back into text.

Use it as often as you like — it's free, with no sign-up and no limits.

  • Developer
  • Free
  • No sign-up
  • Runs in your browser
  • Updated
Mode

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us.

How to use the HTML Entity Encoder

  1. Choose Encode or Decode.
  2. Paste your text.
  3. Copy the result.

What does this tool do?

Characters like < and & must be escaped to appear as text in HTML; otherwise browsers treat them as markup. Escaping user input is also a basic defence against cross-site scripting (XSS).

What gets encoded

Encode escapes the five characters that matter in HTML: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &#39;. So <a href="?q=1&b=2">Tom & Jerry's</a> becomes &lt;a href=&quot;?q=1&amp;b=2&quot;&gt;Tom &amp; Jerry&#39;s&lt;/a&gt;, which a browser shows as text instead of a link.

Tick “Also encode non-ASCII characters” to turn every non-ASCII character into a numeric entity: café becomes caf&#233;, → becomes &#8594; and an emoji like 😀 becomes the single entity &#128512;. That's useful for old systems or email templates that mangle UTF-8.

Decoding, and where escaping isn't enough

Decode turns numeric entities (&#169; and &#xA9;) and named ones (&copy;, &eacute;, &nbsp; and the rest) back into characters. Names are case-sensitive, as in HTML: &Eacute; is É and &eacute; is é. Each run decodes one level, so double-encoded text like &amp;lt; becomes &lt;; run it again to get <. Unknown names are left as they are.

HTML escaping protects text placed inside HTML elements and quoted attributes. It isn't enough inside <script> blocks, inline event handlers or URLs, which need their own encoding. Use your framework's built-in escaping for real applications.

Related: HTML Entities Reference

Why use it?

  • Show code samples on web pages.
  • Decode entities in scraped or exported text.
  • Encode non-ASCII characters for old systems.

Use cases

  • Showing code samples in blog posts and documentation.
  • Fixing text that shows &amp; or &#39; after an export.
  • Preparing strings for HTML email templates.

Example

<a href="?a=1&b=2"> encodes to &lt;a href=&quot;?a=1&amp;b=2&quot;&gt;

Common mistakes

  • Encoding twice, which shows &amp;lt; on the page instead of <.
  • Relying on HTML escaping inside JavaScript or URLs.

Privacy

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.

Frequently asked questions

Which characters must be escaped in HTML?

The essential ones are & (&amp;) and < (&lt;). Inside attribute values, escape quotes as well (&quot;). Most other characters, including accented letters and emoji, work fine as they are in a UTF-8 page.

What's the difference between &nbsp; and a normal space?

&nbsp; is a non-breaking space: it looks like a space, but the browser won't start a new line there. It's useful between a number and its unit, like “10&nbsp;kg”.

Content last updated . See how M2Toolkit works.

Other tools people use alongside the html entity encoder.