HTML Encode
Convert special characters to HTML entities — prevent XSS attacks and display HTML safely in web pages.
What is HTML Encoding?
HTML encoding converts special characters that have meaning in HTML markup into their corresponding HTML entities — text representations that browsers display as the literal character rather than interpreting as HTML. This is a fundamental security and correctness practice in web development.
The five most critical characters to encode are: & (ampersand → &), < (less-than → <), > (greater-than → >), " (double quote → "), and ' (single quote → ' or '). Without encoding these characters, user-supplied content can be interpreted as HTML markup, leading to Cross-Site Scripting (XSS) vulnerabilities.
HTML encoding is required whenever you insert dynamic text content into an HTML page — in element content, attribute values, meta tags, JavaScript strings within HTML, and JSON embedded in HTML. Modern web frameworks like React, Vue, and Angular automatically HTML-encode dynamic content, but vanilla JavaScript and older PHP code requires explicit encoding.
The "encode all chars" option converts every character to its numeric HTML entity (&#XX;), which is useful for obfuscating email addresses from spam bots, encoding content for unusual contexts, or ensuring maximum ASCII-safe output.