HTML Encode
Encode special HTML characters to their entity equivalents.
$html / text
0 chars1 lines
$encoded[READY]
0 chars1 lines
Related Tools
FAQ
- Which characters does HTML encoding replace?
- HTML encoding replaces the five special characters that have meaning in HTML markup: & becomes &, < becomes <, > becomes >, " becomes ", and ' becomes '. These are the minimum set needed to safely embed arbitrary text in HTML.
- Why is HTML encoding important for security?
- Without HTML encoding, user-supplied text that contains < or > can be rendered as HTML tags, enabling cross-site scripting (XSS) attacks. Always encode untrusted input before inserting it into HTML contexts.
- Does HTML encoding affect whitespace or line breaks?
- No. HTML encoding only replaces the five special characters listed above. Whitespace, newlines, and all other printable characters are left unchanged.
HTML encoding converts special characters such as &, <, >, ", and ' into their corresponding HTML entities (&, <, >, ", '). This is essential for safely embedding user-generated content in HTML documents, preventing cross-site scripting (XSS) vulnerabilities, and ensuring that browsers display the characters rather than interpreting them as markup.