🏷️ HTML Entity Encoder
Convert HTML characters like <, >, &, and " to their entity equivalents, or decode HTML entities back to characters.
Related Tools
How to Use the HTML Entity Encoder
The HTML Entity Encoder/Decoder tool converts HTML special characters into their entity equivalents and back. To encode, paste HTML markup or text containing special characters into the left panel and click Encode Entities. Characters like <, >, &, and " are converted to <, >, &, and " respectively. This makes it safe to display HTML source code inside a web page without the browser interpreting it as markup.
To decode, paste text containing HTML entities and click Decode Entities to restore the original characters. HTML entity encoding is critical for security: displaying user-generated content without encoding it first opens your site to XSS (cross-site scripting) attacks, where attackers inject malicious tags. Always encode HTML before inserting untrusted content into a page. This tool processes everything locally in your browser and is useful for blog posts, code documentation, email templates, and CMS content editors.
Frequently Asked Questions
What are HTML entities?
›
HTML entities are special text sequences that represent characters with special meaning in HTML, or characters that cannot easily be typed. They start with & and end with ;. For example, < represents the less-than sign (<), > represents the greater-than sign (>), & represents the ampersand (&), and represents a non-breaking space.
Why do I need to encode HTML characters?
›
If you include raw < or > characters inside HTML content, the browser interprets them as tag delimiters and tries to parse them as HTML, breaking your layout. More seriously, if you include user input in your HTML without encoding, attackers can inject <script> tags and run arbitrary JavaScript on your visitors' browsers — a vulnerability known as XSS (cross-site scripting).
What is XSS and how does HTML encoding prevent it?
›
XSS (Cross-Site Scripting) is a security vulnerability where an attacker injects malicious JavaScript into a web page viewed by other users. HTML encoding prevents XSS by converting < into < so the browser displays it as text rather than interpreting it as a tag opener. Always encode user-supplied input before inserting it into HTML.
What is the difference between HTML encoding and URL encoding?
›
HTML encoding replaces characters that have special meaning inside HTML (like < and &) with entity references (like < and &). URL encoding replaces characters that have special meaning in a URL (like space and &) with percent-encoded sequences (like %20 and %26). You use HTML encoding when inserting data into HTML markup, and URL encoding when inserting data into a URL.