All tools

HTML Entity Encode and Decode

Encoders

Escape text so it shows as text inside HTML, and turn entities like & and é back into characters.

  • Encoder
  • HTML
  • Runs offline
HTML
<a href="/search?q=1&lang=en">Tom & Jerry's "Show"</a>

What HTML entities are

In HTML, < starts a tag and & starts an entity. To show those characters as text, you write them as entities: &lt; for <, &amp; for &. Entities can name any character too — &eacute; is é, &#x1F44B; is 👋.

Escaping is what stops user input from turning into markup: text escaped before it goes into a page cannot become a tag or a script. That only holds for the place it was escaped for — see the last card.

  • The five that matter& < > " ' — escape these and text cannot break out of HTML or a quoted attribute.
  • Named&copy; &mdash; &nbsp; — readable, but only for characters that have a name.
  • Numeric&#233; or &#xE9; works for every character.
  • Context mattersHTML escaping is not JavaScript, CSS or URL escaping. Escape for where the text goes.

How to use the HTML entity encoder

  1. Pick Encode to make text safe to paste into HTML, or Decode to read escaped HTML.
  2. By default only the five special characters are escaped — the minimum that is always correct.
  3. Tick Encode Everything Non-ASCII for a file that must stay ASCII-only; Prefer Named Entities uses &eacute; where a name exists.
  4. Decoding understands every named entity in HTML, plus decimal and hex ones.
  5. If the result still shows entities, it was escaped twice — press Use as Input and decode again.

Examples

Show HTML as text

Paste a snippet into a blog post or docs page without it rendering.

Read escaped text

Text copied from page source or an API, entities and all.

Make text ASCII-only

Every non-ASCII character becomes a named or numeric entity.

Spot double escaping

&amp;amp; on a page means something escaped it twice.

Frequently asked questions

Do I need to escape quotes?

Inside an attribute value, yes — escape the quote that surrounds it, or text can end the attribute early. In normal page text, only & and < are strictly needed; escaping all five is the safe default.

Is escaping enough to prevent XSS?

For text placed in HTML content or a quoted attribute, yes. Not for text placed in a <script>, a style, an event handler or a URL like href — each needs its own escaping. Frameworks that escape by default (React, Jinja) get this right; avoid bypassing them.

Why is &nbsp; different from a space?

&nbsp; is U+00A0, a no-break space: it looks like a space but stops a line break, is not trimmed, and fails string comparisons with a normal space. The Unicode Escapes tool shows which one you have.

&#39; or &apos;?

Both mean an apostrophe in HTML5. &#39; also works in old HTML and in every email client, so it is the safer choice.

Is my text sent anywhere?

No. Encoding and decoding run in your browser; decoded HTML is never rendered or executed.

Related tools

Learn more