HTML Entity Encoder / Decoder

Escape special characters into HTML entities, or decode entities back into readable text, instantly in your browser.

How to Encode or Decode HTML Entities

  1. Paste your text into the Input box.
  2. Click "Encode" to escape special characters (ampersand, less-than, greater-than, and quote marks) into their HTML entity equivalents.
  3. Or click "Decode" to convert entities β€” named, decimal, or hexadecimal β€” back into normal readable text.
  4. The result appears instantly in the Output box.
  5. Click "Copy Output" to copy the result to your clipboard.

Frequently Asked Questions

Why does the order of replacements matter when encoding?

Because the ampersand character itself has to be encoded first. If the less-than and greater-than signs were encoded before the ampersand, the ampersand inside those newly-created entities would get encoded a second time, corrupting the output into a double-escaped entity. Encoding the ampersand first avoids that bug entirely.

What entity formats does the decoder understand?

All of them β€” common named entities such as ampersand, less-than, greater-than, quotation mark, and non-breaking space, decimal numeric entities, and hexadecimal numeric entities. Decoding is handled by the browser's own built-in HTML parser rather than a hand-written lookup table, so it correctly understands the full standard entity set.

Is it safe to decode HTML entities this way?

Yes, in this context. The tool sets your text as the innerHTML of a hidden, detached element purely to read back the decoded textContent β€” the element is never inserted into the page, and your text never leaves your browser, so there's no script-execution risk here.

When do I actually need to encode HTML entities?

Any time you're inserting user-supplied or special text into an HTML page and want reserved characters like the less-than sign, greater-than sign, ampersand, or quote marks to display literally instead of being interpreted as markup β€” for example, showing a code snippet or a quoted string inside a web page.

Will this handle emoji or non-English characters correctly?

Yes β€” only the five reserved HTML characters (ampersand, less-than, greater-than, double quote, and single quote) are touched during encoding; everything else, including emoji, accented letters, and non-Latin scripts, passes through completely unchanged.