Copied!
Encoding Tool

HTML Entity Encoder / Decoder

Encode special characters to HTML entities or decode HTML entities back to readable text. This free online tool converts reserved HTML characters like <, >, &, and " to their entity equivalents, helping prevent Cross-Site Scripting (XSS) attacks. Supports both named entities (&amp;) and numeric entities (&#38;). All processing happens in your browser — nothing is sent to a server.

html-entity.tool
0 characters
Output will appear here...
CharNamedNumericDescription
&&amp;&#38;Ampersand
<&lt;&#60;Less than
>&gt;&#62;Greater than
"&quot;&#34;Double quote
'&#39;&#39;Single quote
 &nbsp;&#160;Non-breaking space
©&copy;&#169;Copyright
&mdash;&#8212;Em dash
&rarr;&#8594;Right arrow
&hellip;&#8230;Ellipsis

Frequently Asked Questions

What are HTML entities and why are they used?
HTML entities are special codes that represent characters which have reserved meaning in HTML (like <, >, &) or characters not available on a standard keyboard (like ©, , ). They follow the format &name; or &#number;. Without entities, browsers would misinterpret these characters as HTML tags or markup, breaking the page layout or creating security vulnerabilities.
How does HTML encoding prevent XSS attacks?
Cross-Site Scripting (XSS) attacks inject malicious HTML or JavaScript into web pages. HTML encoding converts dangerous characters like < and > into their entity equivalents (&lt; and &gt;), so the browser renders them as visible text instead of executing them as code. This is a critical defense — always encode user-generated content before inserting it into HTML. The OWASP Top 10 lists XSS as one of the most common web vulnerabilities.
What is the difference between HTML encoding and URL encoding?
HTML encoding converts characters to HTML entities (&&amp;) for safe display inside HTML documents. URL encoding converts characters to percent-encoded format (space%20) for safe use in URLs. They serve different purposes: HTML encoding prevents markup injection in web pages, URL encoding ensures special characters are transmitted correctly in URLs. They are not interchangeable.
Should I use named or numeric HTML entities?
Named entities like &amp; are more human-readable but not every character has a named version. Numeric entities — decimal (&#38;) or hexadecimal (&#x26;) — work for any Unicode character. For common entities (&lt;, &gt;, &amp;), use named versions for readability. For uncommon or Unicode characters, use numeric entities. Both are valid in all modern browsers and HTML5.
Which character encoding should I use — UTF-8 or ASCII?
UTF-8 — always. The W3C and WHATWG HTML5 spec both recommend UTF-8 as the default character encoding. UTF-8 supports all Unicode characters (emoji, CJK, Arabic, etc.) while remaining backward-compatible with ASCII. Set <meta charset="UTF-8"> in your HTML <head>. Over 98% of websites use UTF-8 as of 2026.