getwordcount.com

HTML Entity Encoder & Decoder

Escape HTML special characters and decode them.

Copied to clipboard

This HTML entity encoder and decoder converts characters like <, > and & into their HTML entities and back. Use it to display code or markup on a web page as text, without the browser trying to render it.

How to use the HTML entity tool

  1. Choose Encode or Decode.
  2. Paste your text, code or HTML.
  3. Copy the escaped or unescaped result.

When to escape HTML

If you want to show an HTML tag on a page — in a tutorial, a code sample or documentation — the special characters must be turned into entities first. Otherwise the browser interprets them as real markup, which breaks your layout and, when the text comes from users, opens the door to cross-site scripting. Escaping the five reserved characters neutralises both problems.

The reserved characters

CharacterEntity
&&amp;
<&lt;
>&gt;
"&quot;
'&#39;

Frequently asked questions

Which characters get encoded?

The five that matter most in HTML: the ampersand, less-than, greater-than, double quote and single quote.

Does it decode numeric entities like &#39;?

Yes. The decoder handles named entities and numeric ones (both decimal and hexadecimal).

Is escaping HTML the same as sanitising it?

Escaping is a big part of safe output, but full sanitisation of untrusted HTML needs a dedicated library. For displaying text safely, escaping is the right tool.

Related tools