Tools

HTML Encoder/Decoder

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

How to Calculate

HTML encoding converts characters with special meaning in HTML into entities. Key conversions: • & → &amp; • < → &lt; • > → &gt; • " → &quot; • ' → &#39; Common use cases: • Displaying code on web pages • Preventing XSS (Cross-Site Scripting) attacks • Safely displaying special characters in HTML documents

Example

Input: <script>alert("XSS")</script> Encoded: &lt;script&gt;alert(&quot;XSS&quot;)&lt;&#x2F;script&gt; Input: Tom & Jerry Encoded: Tom &amp; Jerry

FAQ

Why is HTML encoding necessary?
Characters like <, >, &, and " have special meaning in HTML. Without encoding, browsers may interpret user input as code, creating XSS (Cross-Site Scripting) vulnerabilities.
What happens if I double-encode?
Double encoding turns &amp; into &amp;amp;, which displays as the literal text "&amp;" on screen. Always verify whether input is raw text or already encoded before encoding.
What types of HTML entities exist?
Named: &lt;, &gt;, &amp;, &quot;. Decimal: &#60;, &#62;. Hexadecimal: &#x3C;, &#x3E;. This tool uses the most widely compatible format.
Do I need HTML encoding with React or Vue?
React JSX and Vue templates auto-escape text by default. However, when using dangerouslySetInnerHTML (React) or v-html (Vue), you must manually encode the HTML.

Related Tools