Skip to content
everylittletool

HTML Entity Encoder & Decoder

Escape text for safe use in HTML, or turn HTML entities back into characters.

Runs in your browser — nothing is uploaded

Encoded

<p class="note">Fish & chips — £4.50 “to go”</p>

How to use HTML Entity Encoder & Decoder

  1. 1

    Choose Encode or Decode.

  2. 2

    When encoding, choose Only & < > " ' for standard escaping, or Also non-ASCII to encode accented letters and symbols too.

  3. 3

    Type or paste your text into the box.

  4. 4

    Select Copy to copy the result, or Swap to run it back the other way.

About this tool

Some characters have special meaning in HTML. A < starts a tag and an & starts an entity, so to show them as text they must be written as &lt; and &amp;. Quotes need escaping inside attribute values, as &quot; and &#39;. The default encode mode escapes exactly these five characters, which is what you need to show code samples on a web page or put user text into HTML safely.

Also non-ASCII converts every character outside basic ASCII into an entity: a named one such as &eacute; or &euro; where HTML defines it, otherwise a numeric one such as &#128512;. Untick Use named entities to get only numeric entities. This is rarely needed on a UTF-8 page, but helps when HTML must pass through a system that mangles non-ASCII text, such as some email tools.

Decode turns entities back into characters. It handles decimal (&#169;) and hexadecimal (&#xA9;) numeric entities and all the named entities defined in HTML 4, which covers the ones used in practice, such as &nbsp;, &copy;, &mdash; and &hellip;. A named entity it does not recognise is left unchanged and counted, and the entity must end with a semicolon.

Escaping helps prevent cross-site scripting when you insert text into HTML, but it is not a complete defence on its own: text inside JavaScript, CSS or URLs needs different escaping. Everything runs in your browser.

Questions people ask

What does &amp; mean in HTML?

It is the entity for the & character. If you see &amp;amp; on a page, the text was escaped twice; decode it twice to get back to &.

Which characters must be escaped in HTML?

Always & and <. Also > for safety, and " or ' inside attribute values that use those quotes.

What is the difference between &nbsp; and a normal space?

&nbsp; is a non-breaking space: it looks like a space but stops the browser from wrapping the line at that point.

Should I use named or numeric entities?

Both work in every browser. Named entities are easier to read; numeric entities exist for every Unicode character.