Skip to main content
Developer Tools

HTML Entity Encoder: Encode and Decode HTML Entities

June 2026 ยท 3 min read

Advertisement

728ร—90 Leaderboard

HTML entities are special codes that represent reserved or special characters in HTML. Without them, characters like <, >, and & would break your HTML structure or expose your site to XSS attacks.

The 5 Most Important HTML Entities

&
&amp;

The & symbol starts all HTML entities, so it must always be encoded

<
&lt;

Less-than opens HTML tags โ€” must be encoded in text content

>
&gt;

Greater-than closes HTML tags โ€” encode for safety

"
&quot;

Double quote is used in attribute values โ€” encode inside attr="..."

'
&apos;

Single quote is used in attribute values โ€” encode inside attr='...'

When to Encode HTML Entities

  • โ€ข In template engines: When outputting user-provided data into HTML (prevents XSS)
  • โ€ข In email templates: HTML email clients are strict โ€” always encode special characters
  • โ€ข In attribute values: Any quotes inside attributes need encoding
  • โ€ข Displaying code: Use &lt; and &gt; to show <html> tags visually
  • โ€ข Special symbols: Use &copy;, &trade;, &euro; for ยฉ โ„ข โ‚ฌ in HTML

When NOT to Encode

Don't encode characters that are inside <script> or <style>tags โ€” those contexts have their own escaping rules. Also don't double-encode already-encoded entities (turning &amp; into &amp;amp;).

Encode or decode HTML entities now

Instant conversion ยท Reference table included ยท 100% free

Open HTML Entity Encoder โ†’

Advertisement

336ร—250 Rectangle