HTML entity encoder and decoder

Escape text for HTML (&, <, >, ") or turn named and numeric entities back into characters. Safe and private, runs in your browser.

Runs in your browser. Nothing you paste is uploaded.

How to use it

  1. Choose Encode or Decode.
  2. Paste your text or HTML.
  3. When encoding, optionally turn on Also encode non-English characters to write é, ₹ or Hindi letters as numeric codes.
  4. Copy the result, or press Swap to reverse the operation.

Show code as text, safely

Characters like < and & have special meaning in HTML. To display code or user-written text on a page, they must be written as entities: &lt; for <, &gt; for >, &amp; for &, &quot; for a double quote and &#39; for an apostrophe. Otherwise the browser treats the text as markup, which breaks the page and can open security holes like cross-site scripting (XSS).

Encoding non-English characters as numeric entities (for example &#8377; for ₹) is useful only for old systems or email templates that can't handle UTF-8; modern pages should simply use UTF-8.

Decoding

Decoding turns named entities (&nbsp;, &copy;, &hellip;), decimal (&#169;) and hexadecimal (&#xA9;) entities back into characters. It's useful for cleaning text scraped from web pages, RSS feeds or databases where content was stored escaped. Decoding is done in a way that never runs scripts, so it is safe even for untrusted text.

Questions

Which characters must be escaped in HTML?
In text: & and <. Inside attribute values: also the quote character used around the value. Escaping >, " and ' everywhere is a safe habit.
Is this the same as URL encoding?
No. URL encoding uses % codes for links; HTML entities are for text inside web pages.
Does encoding protect against XSS?
Escaping text before inserting it into HTML is a key defence, but frameworks like React already do it. Never insert untrusted HTML without a sanitiser.
Is what I paste sent to a server?
No. The tool runs as JavaScript in your browser. Your text, files and keys stay on your device, so it is safe to use with internal data, tokens and customer records. It keeps working offline after the page has loaded once.

More free tools