📝

HTML Encode

Encode HTML entities

Frequently Asked Questions

What is HTML encoding?

HTML encoding converts special characters to HTML entities so they display correctly in web pages. < becomes &lt;, > becomes &gt;, & becomes &amp;, " becomes &quot;. This prevents browsers from interpreting them as HTML tags.

Why is HTML encoding important for security?

HTML encoding prevents Cross-Site Scripting (XSS) attacks. Without encoding, user input like <script>alert("hack")</script> would execute as JavaScript. Encoding converts it to harmless display text.

Which characters need to be HTML encoded?

Essential: < > & " ' (the five special HTML characters). Optional but recommended: non-ASCII characters like © (©), em dash (—), and curly quotes. The encoder handles all characters that could cause display or security issues.

Can I encode an entire HTML document?

You can, but typically you only encode user-generated content or text that will be inserted into HTML. Encoding an entire document would convert all tags to visible text. The encoder is designed for text content, not full HTML documents.

What is the difference between HTML encoding and escaping?

They are essentially the same concept. "Encoding" converts characters to entity references. "Escaping" is the broader term for making special characters safe. In HTML context, both refer to replacing < > & " with their entity equivalents.