DevGizmo

HTML Entity Encoder / Decoder

Encode characters to HTML entities and decode entities back to plain text. Safely escape HTML for display in web pages.

What Are HTML Entities?

HTML entities are special sequences that represent characters which have special meaning in HTML markup, or characters that cannot easily be typed. The five most important are:&amp; (&), &lt; (<), &gt;(>), &quot; ("), and &#x27; ('). Encoding these characters prevents the browser from misinterpreting content as HTML markup, and is essential for preventing cross-site scripting (XSS) attacks.

Entity Formats

  • Named entities: &amp;, &copy;, &euro; — human-readable
  • Decimal numeric: &#169; for © — universal
  • Hex numeric: &#xA9; for © — compact

This tool encodes the five unsafe characters as named entities and all other non-ASCII characters as uppercase hex numeric entities. The decoder handles all three formats.

Use Cases

HTML entity encoding is used when embedding user-generated content in HTML pages, displaying code examples in documentation, outputting special symbols (©, ®, €, £) in HTML without charset issues, writing HTML email templates, and escaping strings for use in HTML attributes. Always encode untrusted input before inserting it into an HTML document to prevent XSS vulnerabilities.