Skip to content
Free developer tool

HTML entity encoder

This HTML entity encoder replaces characters that have a special meaning in HTML with entities, such as &lt; for <. Web developers and writers use it to show code samples or user text on a page without the browser treating it as markup.

  • Runs in your browser
  • Free, no account needed
  • Copy or download the result

Your input

32 characters

Non-ASCII

Result

&lt;a title=&quot;Tea &amp; coffee&quot;&gt;Café&lt;/a&gt;

The short answer

HTML entities let you write characters that HTML would otherwise read as markup: & becomes &amp;, < becomes &lt;, > becomes &gt; and quotes become &quot; or &#39;. Escaping text before placing it in a page stops it being read as a tag. It is escaping for display, not a cleaner for untrusted HTML.

Formula& to &amp;, < to &lt;, > to &gt;, " to &quot;, ' to &#39;

Worked example<a title="Tea & coffee">Café</a> becomes &lt;a title=&quot;Tea &amp; coffee&quot;&gt;Café&lt;/a&gt;, with the é left as it is.

Example

Input
<a title="Tea & coffee">Café</a>
Result
&lt;a title=&quot;Tea &amp; coffee&quot;&gt;Café&lt;/a&gt;

How to use the html entity encoder

  1. Paste your text into the Text to escape box.
  2. Set Non-ASCII to Keep Unicode or Numeric entities.
  3. The escaped text updates as you type.
  4. Press Copy result or Download.

How it works

Five characters are always escaped: & becomes &amp;, < becomes &lt;, > becomes &gt;, a double quote becomes &quot; and an apostrophe becomes &#39;.

Numeric entities writes every character above ASCII as a hex reference, so é becomes &#xe9;.

The output is meant for an HTML text node or a quoted attribute value.

This is not an HTML sanitizer. It does not clean up HTML you want to keep, and it does not escape text for JavaScript, CSS or URLs.

An unpaired surrogate, which is half of an emoji left over after bad copying, causes an error.

Everything runs in your browser. Your input is not uploaded or stored. If you use Copy link, what you entered is placed in the link.

Questions and answers

Does escaping HTML prevent XSS?

Escaping helps against cross-site scripting (XSS) when you place untrusted text inside HTML text or a quoted attribute. It is not enough inside script tags, style blocks, event handler attributes or URLs, which need their own escaping.

Why convert non-ASCII characters to numeric entities?

Most modern pages handle Unicode fine. Numeric entities help when a file or system only accepts plain ASCII characters.

Why is the apostrophe written as &#39;?

The numeric form &#39; works in every version of HTML, while the named form &apos; is not supported by some older HTML parsers.

Is my text sent anywhere?

No. Escaping runs in your browser, and you can turn the result back with the HTML entity decoder.

Last updated November 1, 2026. Maintained by SnowRock. How our tools work

All 220 SnowRock tools