HTML / Entity Encoder-Decoder

Encodes text to HTML entities (e.g. < → &lt;) or decodes entities back. The conversion happens entirely in your browser; the text is not sent to a server.

Mode
Encoding scope
"Special characters only" is enough for HTML body/attributes. "All non-ASCII" makes the output pure ASCII (legacy system / email compatibility).
Input
Enter the text to encode or decode. The output updates as you type.

Output

Enter text in the field on the left; the result appears instantly.

Frequently Asked Questions

What is the difference between HTML encoding and URL encoding?

HTML encoding converts characters that are meaningful in an HTML document (< > & " ') into entities so the browser does not treat the text as markup. URL encoding (percent-encoding) converts characters that are unsafe in a URL into %XX form. They serve different contexts and are not interchangeable.

Which characters must always be encoded in HTML?

At minimum five characters: & (&amp;), < (&lt;), > (&gt;), " (&quot;) and ' (&#39;). The & must be encoded first, otherwise the other entities break. Encoding the quote character is critical when attribute values are quoted.

Why is &#39; used instead of &apos;?

The named entity &apos; is defined in HTML5 but did not exist in HTML4 and some older browsers. The numeric reference &#39; works in every version, so it is the safest, most portable choice for a single quote. This tool emits &#39; on encode.

How do I HTML-encode in .NET?

System.Net.WebUtility.HtmlEncode(string) works with no dependencies; in web projects System.Web.HttpUtility.HtmlEncode is also available. In Razor, @variable expressions automatically HTML-encode the output — printing raw HTML deliberately requires @Html.Raw.

Does this tool fully prevent XSS?

Not on its own. HTML encoding is the correct defence when printing data into an HTML body; but attribute, JavaScript, CSS and URL contexts need different escaping rules. The right approach is context-aware encoding + a Content Security Policy + input validation. This tool helps you see and verify the encoding.