Our free online HTML Encoder & Decoder converts special characters to HTML entities and decodes them back. Essential for preventing XSS attacks and displaying special characters safely in HTML.
HTML encoding converts characters that have special meaning in HTML into their entity equivalents. This prevents browsers from interpreting the characters as HTML markup. For example, < becomes < so it displays as a less-than sign instead of starting a tag.
< → < (less than)
> → > (greater than)
& → & (ampersand)
" → " (double quote)
' → ' (single quote/apostrophe)
→ non-breaking space
Cross-Site Scripting (XSS) attacks inject malicious scripts into web pages. HTML encoding user input prevents scripts from executing. Always encode: user comments, form inputs, URL parameters, and any untrusted data.
Named: © → © (easier to read)
Decimal: © → © (numeric code)
Hexadecimal: © → © (hex code)
Numeric entities work for any Unicode character.
• Displaying user-generated content
• Showing code snippets in HTML
• Including special characters in attributes
• Preventing markup interpretation
• Email templates with special characters
Different contexts require different encoding:
HTML Body: Encode < > &
HTML Attributes: Also encode " '
JavaScript: Use JavaScript escaping
CSS: Use CSS escaping
URLs: Use URL encoding
Script Injection: <script>alert('XSS')</script>
Event Handlers: <img onerror="alert('XSS')">
URL Schemes: <a href="javascript:alert('XSS')">
CSS: style="background:url(javascript:...)"
© © Copyright
® ® Registered
™ ™ Trademark
€ € Euro
£ £ Pound
♥ ♥ Heart
• Always encode output, never trust input
• Use context-appropriate encoding
• Implement Content Security Policy (CSP)
• Use frameworks with auto-escaping
• Validate and sanitize on the server side too