HTML Entity Encoder / Decoder

HTML Entity Encoder & Decoder

Encode special characters to HTML entities or decode them back instantly

Plain Text
Encoded Output
Output will appear here...

Common HTML Entities Reference

CharacterNamedDecimalHexDescription
&&&&Ampersand
<&lt;&#60;&#x3C;Less than
>&gt;&#62;&#x3E;Greater than
"&quot;&#34;&#x22;Double quote
'&apos;&#39;&#x27;Apostrophe / single quote
 &nbsp;&#160;&#xA0;Non-breaking space
©&copy;&#169;&#xA9;Copyright sign
®&reg;&#174;&#xAE;Registered sign
&trade;&#8482;&#x2122;Trademark sign
&mdash;&#8212;&#x2014;Em dash
&ndash;&#8211;&#x2013;En dash
&euro;&#8364;&#x20AC;Euro sign
£&pound;&#163;&#xA3;Pound sign
¥&yen;&#165;&#xA5;Yen sign
¢&cent;&#162;&#xA2;Cent sign
&hearts;&#9829;&#x2665;Heart suit
«&laquo;&#171;&#xAB;Left double angle quote
»&raquo;&#187;&#xBB;Right double angle quote
&bull;&#8226;&#x2022;Bullet
&hellip;&#8230;&#x2026;Horizontal ellipsis
&larr;&#8592;&#x2190;Left arrow
&rarr;&#8594;&#x2192;Right arrow
°&deg;&#176;&#xB0;Degree sign
×&times;&#215;&#xD7;Multiplication sign
÷&divide;&#247;&#xF7;Division sign

What Are HTML Entities?

HTML entities are special sequences of characters used to represent reserved characters and symbols in HTML. Because characters like <, >, and & have special meaning in HTML markup, they must be encoded as entities (&lt;, &gt;, &amp;) to be displayed as literal text in a web page.

Each entity begins with an ampersand (&) and ends with a semicolon (;). Between them is either a named reference (like amp), a decimal number preceded by #, or a hexadecimal number preceded by #x.

Why HTML Encoding Matters: XSS Prevention

One of the most important reasons to encode HTML entities is to prevent Cross-Site Scripting (XSS) attacks. XSS occurs when an attacker injects malicious scripts into web pages viewed by other users. If user-supplied input is rendered as raw HTML without encoding, an attacker could insert <script> tags or event handlers that execute arbitrary JavaScript.

By encoding characters like < and > to their entity equivalents before rendering, browsers treat them as display text rather than HTML markup. This is a fundamental security practice for any web application that displays user-generated content.

Named vs Numeric Entities

HTML supports three formats for encoding entities. Each produces the same visual result but uses different syntax:

FormatSyntaxExamplePros
Named&name;&amp;Human-readable, easy to remember
Decimal&#number;&#38;Works for any Unicode character
Hexadecimal&#xHEX;&#x26;Matches Unicode code points directly

Named entities are the most readable but only cover a limited set of characters. Numeric entities (decimal or hexadecimal) can represent any Unicode character, making them more versatile for internationalization and special symbols.

Common Use Cases

Displaying Code Snippets

Show HTML or XML source code on a web page without browsers interpreting the tags as markup.

XSS Prevention

Sanitize user input before rendering it in HTML to prevent injection of malicious scripts.

Email Templates

Encode special characters in HTML emails to ensure consistent rendering across email clients.

CMS & Blog Content

Safely embed special characters, symbols, and typographic marks in content management systems.

Internationalization

Represent characters from non-Latin scripts when the document encoding might not support them directly.

XML & RSS Feeds

Encode reserved XML characters in feed content to produce valid, well-formed XML documents.

Frequently Asked Questions

Named entities use a human-readable name (like &amp; for the ampersand), while numeric entities use the character's Unicode code point in either decimal (&#38;) or hexadecimal (&#x26;) form. Named entities are easier to read but only exist for a subset of characters. Numeric entities can represent any Unicode character.

HTML uses certain characters as part of its syntax (like < and > for tags, & for entities). If you want to display these characters as text on a web page, you must encode them as entities. Failing to do so can cause broken layouts, invalid HTML, or security vulnerabilities like Cross-Site Scripting (XSS).

Cross-Site Scripting (XSS) is a security vulnerability where attackers inject malicious scripts into web pages. HTML encoding converts characters like < and > into their entity equivalents (&lt; and &gt;), so browsers display them as text rather than interpreting them as HTML tags. This prevents injected script tags from executing.

Yes. This tool runs entirely in your browser using client-side JavaScript. Your text is never uploaded, transmitted, or stored on any server. You can verify this by using the tool with your network tab open — no requests are made.

Yes. Enable the 'Non-ASCII' checkbox in encode mode to convert any character with a code point above 127 into its numeric HTML entity. This is useful when your document encoding might not support certain characters directly.

Named entities (&amp;, &lt;, etc.) are the most readable and are recommended for common characters. Decimal entities (&#38;) have the widest browser support. Hexadecimal entities (&#x26;) match Unicode code points directly and are preferred when working with Unicode character tables. All three are valid in HTML5.

This tool supports the most commonly used named entities including &amp;, &lt;, &gt;, &quot;, &apos;, &nbsp;, &copy;, &reg;, &trade;, &euro;, &pound;, &yen;, &hearts;, and more. For characters without a named entity, use decimal or hexadecimal numeric encoding.

HTML encoding converts characters to HTML entity references (like &amp; for &) for safe display in HTML documents. URL encoding (percent-encoding) converts characters to percent-encoded sequences (like %26 for &) for safe transmission in URLs. They serve different purposes and use different syntax.