Account

What new tool do you want?

Developer Tools

HTML Entity Encoder / Decoder

Escape <, >, & and quotes as HTML entities, or decode named and numeric entities (&amp;, &#169;, &#x1F600;) back to text.

How to use

  1. 1Choose Encode or Decode.
  2. 2Paste your text or HTML and copy the result.

Frequently asked questions

Which characters must be escaped in HTML?

& and < always; > for safety; and " or ' inside attribute values. Everything else can be written as-is in UTF-8 pages.

What does 'Encode all non-ASCII' do?

Also turns characters like é or emoji into numeric entities (&#233;), useful for systems that aren't UTF-8 safe.

Does escaping prevent XSS?

Escaping text inserted into HTML is one key defense, but attributes, URLs and scripts need context-specific handling too.

Worked example: HTML Entity Encoder / Decoder

Encode <a href="x">Tom & 'Jerry'</a> and you get &lt;a href=&quot;x&quot;&gt;Tom &amp; &#39;Jerry&#39;&lt;/a&gt; — every angle bracket, ampersand and quote (both double and single) is escaped, which is deliberately more aggressive than the HTML spec strictly requires (only & and < are mandatory), because escaping quotes too makes the output safe to drop straight into an HTML attribute value as well as into text content. Decoding &lt;p&gt; &copy; &#169; &#x1F600; &bogus; shows the three entity forms side by side: a named entity (&copy; → ©), a decimal numeric entity (&#169; → the same ©), a hex numeric entity (&#x1F600; → 😀), and critically, &bogus; is left untouched exactly as written — the decoder only replaces entities it actually recognizes.

What "encode all non-ASCII" is actually for

By default, only the handful of characters with real HTML meaning (< > & " ') get escaped — é and 😀 pass through unchanged because modern pages are UTF-8 and render them natively. Toggling "encode all non-ASCII" instead converts every character above code point 126 into a numeric or named entity (é → &eacute;, 😀 → &#128512;), which matters specifically for systems that aren't reliably UTF-8-safe — older email templating systems, some legacy CMS import pipelines, or XML contexts with a declared non-UTF-8 encoding — where a raw multi-byte character can get mangled in transit but a plain-ASCII entity reference always survives.

Why escaping HTML text doesn't fully solve XSS

Escaping solves exactly one injection context: untrusted text being inserted as HTML content between tags. It does nothing to protect an attribute value if you're building attrs as unescaped-but-unquoted HTML, nothing to protect a value inserted inside a <script> block or an onclick= handler, and nothing to protect a URL inserted into an href. Each of those needs its own escaping rules (attribute escaping, JavaScript string escaping, URL encoding) — treating HTML entity escaping as a universal XSS fix is a common and genuinely dangerous mistake.

The non-ASCII switch disappears when I am decoding

Mode opens on encode. Encode all non-ASCII starts off, and that switch is hidden as soon as I pick decode. With it off, the ordinary pass still turns angle brackets, ampersands, and quotes into entities. The sample with Tom and Jerry shows the ampersand as an amp entity and the apostrophe as a numeric entity. With the switch on, any character past basic ASCII becomes a named entity when one exists, and a numeric entity when it does not. Decode does not offer that switch, because there is nothing left to decide. I stay on encode when I want the extra pass.

Related tools

More: Developer Tools