HTML Entity Encoder / Decoder

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

Named uses letters like &, Decimal uses &, Hex uses &. Decoding automatically understands all three, regardless of which one is selected here.

How to Encode or Decode HTML Entities

  1. Paste your text into the Input box.
  2. Pick an entity format — Named, Decimal, or Hex — for how encoded characters should be written.
  3. Optionally turn on "Also encode all non-ASCII characters" if you want accented letters, symbols, and emoji escaped too, not just the HTML-special ones.
  4. Click "Encode" to escape special characters (ampersand, less-than, greater-than, and quote marks — plus non-ASCII characters if that option is on) into HTML entities in your chosen format.
  5. Or click "Decode" to convert entities — named, decimal, or hexadecimal — back into normal readable text.
  6. The result appears instantly in the Output box.
  7. Click "Copy Output" to copy the result to your clipboard.

Frequently Asked Questions

Why doesn't encoding accidentally double-escape the ampersands inside newly created entities?

Because the tool scans your original input exactly once and converts each character independently into its entity form — it never re-scans its own output. A naive approach that does sequential find-and-replace passes (encoding the less-than sign before the ampersand, for example) can accidentally re-encode the ampersand inside an entity it just created, corrupting the result into a double-escaped entity. Encoding in a single pass over the source text 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?

By default, yes — only the five reserved HTML characters (ampersand, less-than, greater-than, double quote, and single quote) are touched during encoding, so emoji, accented letters, and non-Latin scripts pass through completely unchanged. Turning on the "Also encode all non-ASCII characters" option changes that: every character outside the basic ASCII range, including emoji and accented letters, gets converted into an entity too, which is useful when you need output that's restricted to plain ASCII.

What's the difference between the Named, Decimal, and Hex entity formats?

They're three ways of writing the same entity. Named entities use a short mnemonic word, like & for an ampersand or é for é. Decimal numeric entities use the character's Unicode code point in base 10, like & or é. Hexadecimal numeric entities use the same code point in base 16, like & or é. All three decode back to the exact same character — the format only changes how the entity looks in your markup. Named entities are only defined for a limited set of characters (the five reserved HTML characters plus the Latin-1 accented letters and common symbols); any other Unicode character selected for encoding automatically falls back to a decimal numeric entity, since HTML has no named entity for it.