Developer Tools

HTML Entity Encoder

Encode HTML special characters to entities or decode HTML entities back to readable text.

Input
Output
About this tool

HTML entities are used to display reserved characters in HTML without triggering browser interpretation. The less-than sign (<) must be written as &lt; in HTML to prevent the browser from treating it as a tag opening. Ampersands (&) become &amp;. This is essential when displaying user-supplied content in web pages to prevent cross-site scripting (XSS) vulnerabilities.

Common HTML entities

&lt; produces <. &gt; produces >. &amp; produces &. &quot; produces ". &apos; or &#39; produces '. &nbsp; produces a non-breaking space. &copy; produces ©. &reg; produces ®. &mdash; produces —.

Frequently asked questions

Why do I need HTML entity encoding for user input?

If you display user-submitted text in a web page without encoding it, a user can inject HTML or JavaScript that runs in other visitors' browsers. This is a cross-site scripting (XSS) attack. Encoding converts <script> to &lt;script&gt;, which displays as text instead of executing as code.

Related tools