Encode HTML Entities

Encode special characters as HTML entities (< → &lt;), or decode them back.

Input

Output

Words 8Characters 39Without spaces 32Sentences 1Lines 1Paragraphs 1Reading time < 1 min

About HTML Entity Encoder

When you want to show code or user text on a web page without the browser treating it as markup, the special characters need escaping. This encoder turns < into &lt;, > into &gt;, & into &amp; and quotes into &quot; and &#39;.

Tick Encode non-ASCII characters to also convert accents, currency signs and emoji into numeric entities such as &#233;, which helps with systems that only accept plain ASCII. Encoding happens in your browser and nothing is uploaded.

How to use it

  1. Paste the text or HTML snippet you want to escape.
  2. Keep Mode on Encode, and tick Encode non-ASCII characters if needed.
  3. Copy the escaped text from the right, or download it as a .txt file.

Frequently asked questions

Which characters are encoded?

By default the five that matter in HTML: &, <, >, the double quote and the apostrophe. With the non-ASCII option on, every character above the basic ASCII range is encoded as a numeric entity as well.

Is this enough to stop XSS?

Escaping these five characters makes text safe to place between tags and inside quoted attribute values. Other places, such as inside script tags or URLs, need their own escaping.

How do I turn entities back into characters?

Use the HTML entity decoder, which converts &lt;, &amp;, &#233; and similar back to normal text.

Related tools