Try the HTML Entities

HTML Entities — Encode & Decode Special Characters for Correct, Safe HTML

Learn what HTML entities are, why they exist, the most common named entities, how numeric entities work for any Unicode character, and when modern UTF-8 pages don't need them — with a free HTML entities tool.

By sadiqbd · June 7, 2026

Share:
HTML Entities — Encode & Decode Special Characters for Correct, Safe HTML

HTML entities are what keep your web page from breaking when displaying special characters

The browser interprets <, >, and & as HTML syntax characters. If your content includes these characters literally — a code example showing <div>, a mathematical expression with &, a price with < or > — the browser either misinterprets them or renders the page incorrectly. HTML entities are the solution: escaped representations of these characters that the browser displays correctly without misinterpreting as markup.


Why HTML Entities Exist

HTML is a text format that uses <, >, and & for structure. This creates a problem when you want to display these characters as content:

  • <p>Price: 5 < 10</p> — the < might confuse the parser
  • <p>Company: Johnson & Johnson</p> — the & might be misinterpreted as starting an entity
  • <code>&lt;div class="container"&gt;</code> — this is how you safely display HTML code in HTML

HTML entities are the escape mechanism:

  • &lt; displays <
  • &gt; displays >
  • &amp; displays &
  • &quot; displays "
  • &apos; or &#39; displays '

Common HTML Entities Reference

Essential characters

Character Named entity Numeric (decimal) Numeric (hex)
< &lt; &#60; &#x3C;
> &gt; &#62; &#x3E;
& &amp; &#38; &#x26;
" &quot; &#34; &#x22;
' &apos; &#39; &#x27;
(space) &nbsp; &#160; &#xA0;

Typographic characters

Character Entity Use
© &copy; Copyright
® &reg; Registered trademark
â„¢ &trade; Trademark
€ &euro; Euro sign
£ &pound; Pound sterling
— &mdash; Em dash
– &ndash; En dash
… &hellip; Ellipsis
" &ldquo; Left double quote
" &rdquo; Right double quote
· &middot; Middle dot (bullet)
× &times; Multiplication sign
÷ &divide; Division sign

Mathematical symbols

Character Entity
≤ &le;
≥ &ge;
≠ &ne;
± &plusmn;
° &deg;
½ &frac12;
¼ &frac14;
¾ &frac34;
∞ &infin;

How to Use the HTML Entities Tool on sadiqbd.com

Encoding (text to entities):

  1. Paste text containing special characters
  2. The tool converts characters like <, >, &, " to their HTML entity equivalents
  3. Copy the encoded HTML-safe output

Decoding (entities to text):

  1. Paste HTML with entity codes
  2. The tool converts entities back to the actual characters
  3. Copy the decoded text

Real-World Examples

Displaying code in HTML

You're writing documentation and want to show this HTML snippet:

<div class="container">
  <p>Hello & welcome</p>
</div>

In HTML, you'd need to encode this before putting it in <pre><code> tags:

<pre><code>&lt;div class=&quot;container&quot;&gt;
  &lt;p&gt;Hello &amp; welcome&lt;/p&gt;
&lt;/div&gt;</code></pre>

Without encoding, the browser would try to render the inner HTML as actual HTML elements.

Company names with ampersands

Johnson & Johnson, AT&T, Marks & Spencer — these contain & which must be encoded in HTML:

<p>Johnson &amp; Johnson</p>
<p>AT&amp;T</p>

Most modern HTML parsers are forgiving about bare & in content, but it's technically incorrect and can cause issues in XML-based contexts (XHTML, SVG, XML feeds).

Email templates

HTML emails are parsed by many different email clients with varying levels of strictness. Using proper entity encoding for &, <, >, and special characters ensures consistent rendering across Gmail, Outlook, Apple Mail, and mobile clients.

Database-stored HTML

When users submit content that gets stored in a database and later displayed as HTML, all user input must be entity-encoded before display to prevent XSS (Cross-Site Scripting) attacks:

User input: <script>alert('hacked')</script> Stored and encoded: &lt;script&gt;alert(&#39;hacked&#39;)&lt;/script&gt; Browser displays: <script>alert('hacked')</script> — as text, not executed

This is the core of output encoding for XSS prevention.

Mathematical content

A page comparing prices: "The sale price is less than < the original." In HTML:

<p>The sale price is less than &lt; the original.</p>

Or using the character directly: in HTML5, a bare < in text content (not inside a tag) is generally safe — but using &lt; is more robust and universally correct.


Named Entities vs. Numeric Entities

Every character representable as an HTML entity has both named and numeric forms:

Named: &amp; — human-readable, well-known for common characters Numeric decimal: &#38; — works for any Unicode character, not just named ones Numeric hex: &#x26; — hexadecimal form, same coverage as decimal

For characters without named entities (e.g., Bangla characters, emoji), use numeric form: &#2472; for প (Bengali letter pa).


When NOT to Use HTML Entities

Modern HTML5 UTF-8 pages don't need entities for most characters. If your page declares <meta charset="UTF-8"> and is served with the correct encoding header, characters like é, ñ, ü, and even Bengali characters can be used directly in source — no entities needed.

Entities are primarily needed for:

  1. The five reserved characters: <, >, &, ", '
  2. Invisible characters where the literal character would be confusing (non-breaking space &nbsp;)
  3. Legacy encodings or contexts where UTF-8 isn't guaranteed

Frequently Asked Questions

What's the difference between &quot; and &#34;? Both represent the double quote character ". Named entities (&quot;) are more readable; numeric entities (&#34;) work for any Unicode character. Use named where available for readability.

When should I use &nbsp; instead of a regular space? When you need a space that doesn't allow line breaking — such as between "Mr." and "Smith" (preventing a line break between the title and name), or before a unit like "50 kg." Use sparingly; non-breaking spaces in unexpected places cause layout and copy-paste issues.

Is the HTML entities tool free? Yes — completely free, no sign-up required.


HTML entities are one of the fundamentals that separates correctly written HTML from HTML that mostly works. The entities tool makes encoding and decoding any set of special characters immediate.

Try the HTML Entities tool free at sadiqbd.com — encode or decode any text with HTML entities instantly.

Share:
Try the related tool:
Open HTML Entities

More HTML Entities articles