🏷️

HTML Entity Encoder/Decoder

Encode and decode HTML entities

About This Calculator

HTML entities are special codes that represent characters which have reserved meanings in HTML or are not easily typed on a keyboard. This tool encodes characters like <, >, &, and " into their HTML entity equivalents (&lt;, &gt;, &amp;, &quot;) and decodes entities back to characters. It handles named entities, decimal numeric references (&#60;), and hexadecimal references (&#x3C;). Developers need HTML entity encoding to prevent XSS vulnerabilities when displaying user input, to correctly render special characters in HTML documents, and to include symbols like copyright (©), em dashes (—), and non-breaking spaces (&nbsp;) in web content.

How to Use

  1. 1
    Paste your text
    Enter text containing special characters or HTML entities.
  2. 2
    Choose encode or decode
    Select whether to convert to HTML entities or back to characters.
  3. 3
    Copy the result
    Copy the encoded or decoded text to use in your HTML.

Frequently Asked Questions

Q. Why do I need to encode HTML entities?
Characters like <, >, and & have special meaning in HTML. If user-submitted text contains these characters and you render it without encoding, the browser interprets them as HTML tags or entities, potentially breaking your layout or enabling XSS attacks. Always encode untrusted content before inserting it into HTML.
Q. What is the difference between named and numeric HTML entities?
Named entities use memorable labels like &amp; for & and &copy; for ©. Numeric entities use Unicode code points like &#38; (decimal) or &#x26; (hex) for &. Numeric entities work for any Unicode character; named entities exist only for common symbols.
Q. When should I use &nbsp; in HTML?
Use &nbsp; (non-breaking space) to prevent a line break between two words that should stay together, like "100 km" or "Dr. Smith". Avoid using it for layout spacing — use CSS margin and padding instead.

Disclaimer: Results are for informational purposes only and do not constitute professional advice. Always consult qualified professionals for important decisions.