HTML Encode Online

Convert special characters to HTML entities for safe display.

Need to decode? Go to HTML Decode

What Is HTML Encoding?

HTML encoding converts special characters into their HTML entity equivalents. For example, < becomes &lt;, > becomes &gt;, and & becomes &amp;. This ensures characters are displayed literally rather than being interpreted as HTML markup.

Security: HTML encoding is a critical defense against Cross-Site Scripting (XSS) attacks. Always encode user-generated content before inserting it into HTML pages.

Characters That Need HTML Encoding

  • &&amp; — Ampersand
  • <&lt; — Less than
  • >&gt; — Greater than
  • "&quot; — Double quote
  • '&#39; — Single quote / apostrophe

Frequently Asked Questions

When should I use HTML encoding?

Always encode text when inserting user-provided content into HTML. This includes form inputs, database values, API responses, and any other data that could contain HTML characters.