HTML Entity Encoder

Escape and unescape HTML entities.

Result

The result will appear here.

About the HTML Entity Encoder

Escape and unescape HTML entities so reserved characters render safely in markup. Converts characters like <, > and & to entities (and back) — useful when displaying code or user input in HTML.

How to use it

  1. 1Paste text to escape, or entities to unescape.
  2. 2Switch direction as needed.
  3. 3Copy the result into your markup.

Showing code and symbols safely in HTML

When you want a page to display a literal < or & rather than treat it as the start of a tag, you escape it to an HTML entity — &lt; or &amp;. This is essential any time you show code samples, or render text that came from a user, inside a page: without escaping, a stray angle bracket can break the layout, and malicious input can inject scripts (an XSS attack). Unescaping does the reverse, turning entities back into their characters so you can read content that was stored in escaped form. Both directions run locally in your browser.

Common uses

  • Displaying HTML or XML code samples on a page as literal text.
  • Escaping user-supplied text before inserting it into markup.
  • Decoding entity-encoded content back into readable characters.

Frequently asked questions

Why escape HTML entities?
Escaping reserved characters prevents them from being interpreted as markup, which avoids broken layout and cross-site scripting (XSS).
Which characters need escaping?
Chiefly <, >, & and quotes. Left unescaped, these can break your layout or let injected markup run, so they're converted to entities like &lt;, &gt; and &amp;.