HTML Entities

Escape HTML special characters as entities (& < > "), or decode entities to plain text.

HTML escaping example

Five characters have a meaning in HTML markup and are replaced by entities, so a browser shows them as text and does not interpret them:

<a href="x">Tom & Jerry</a>
→
&lt;a href=&quot;x&quot;&gt;Tom &amp; Jerry&lt;/a&gt;

Decoding accepts named entities, decimal references and hexadecimal references alike: &copy;, &#169; and &#xA9; all become ©, and &#8364; becomes €. A non-breaking space, &nbsp;, decodes to the character U+00A0, which looks like a space and is not equal to one in a comparison.

When escaping goes wrong

  • Double escaping. Text that is escaped twice shows &amp;lt; in the source and &lt; on the page. This happens when a template engine escapes a value that was already escaped before it was stored. Store raw text and escape once, at output.
  • The wrong context. Entity escaping protects text between tags and inside quoted attribute values. It does not make a value safe inside a <script> block, a style attribute or a URL; those contexts need JavaScript, CSS or URL encoding.
  • Unquoted attributes. In <input value=a b> the value ends at the space. Escaping the five characters does not help there; quote every attribute value.
  • Non-ASCII characters. Letters such as é or ü do not need entities on a page served as UTF-8, and this tool leaves them unchanged when encoding.

Related tools

Monitor HTML Entities automatically

Escape HTML special characters as entities (&amp; &lt; &gt; &quot;), or decode entities to plain text. NetTests can run this check on a schedule, preserve historical results, compare changes over time, and alert you the moment something breaks.

Start monitoring free → See all monitoring products

Frequently Asked Questions

What are HTML entities?

HTML entities are text representations of characters that have special meaning in HTML. For example < represents <, & represents &, and " represents a double quote. They prevent the browser from interpreting the characters as HTML markup.

Why is HTML escaping important for security?

Inserting user-supplied text into HTML without escaping creates Cross-Site Scripting (XSS) vulnerabilities. An attacker can inject <script> tags that run arbitrary JavaScript in other users' browsers. HTML escaping is the primary defence: always escape untrusted data before rendering it in HTML templates.

Which characters get escaped?

The five critical characters: < → &lt;, > → &gt;, & → &amp;, " → &quot;, and ' → &#x27;. Most templating engines (Jinja2, Django, React JSX) do this automatically — manual escaping is only needed when bypassing the auto-escape.