Developer tool

HTML Entity Encoder & Decoder

Paste text, choose a direction and convert HTML special characters instantly.

Runs in your browser. No upload.

Runs only in your browser.

About this tool

HTML Entity Encoder & Decoder made simple.

Useful for writing safe HTML snippets, debugging encoded text and checking entities without sending your content to a server.

Guide

Using HTML Entity Encoder & Decoder

This tool converts text to HTML entities and back. Encode HTML swaps the five characters that have a special meaning in HTML, which are the ampersand, the two angle brackets and the two kinds of quote mark, for their entity codes so they show up as plain text. Decode HTML turns entities such as & or é back into readable characters. It does not check or clean HTML for safety.

How to use it

  1. Pick Encode HTML to turn special characters into entities, or Decode HTML to turn entities back into characters. Encode is selected when the page opens.
  2. Paste or type your text into the Text to convert box.
  3. Press Convert. The converted text appears in the Result box. Changing the direction does not convert anything by itself, so press Convert again after you switch.
  4. Press Copy result to copy the output, or Clear to empty both boxes.

Worked examples

Encoding a snippet

You enter
Direction
Encode HTML
Text
<p class="intro">Tom & Jerry's café</p>
You get
Result
&lt;p class=&quot;intro&quot;&gt;Tom &amp; Jerry&#39;s café&lt;/p&gt;

The brackets, both quote marks and the ampersand are replaced. The letter é is left as it is, because Encode only touches those five characters.

Run through the tool’s own code.

Decoding entities

You enter
Direction
Decode HTML
Text
&lt;p&gt;Tom &amp; Jerry&#39;s caf&eacute;&lt;/p&gt;
You get
Result
<p>Tom & Jerry's café</p>

Named entities such as &eacute; and numeric ones such as &#39; both become their characters. The tags in the result are plain text, not live HTML.

Run through the tool’s own code.

A query string that changes

You enter
Direction
Decode HTML
Text
page?a=1&not=3
You get
Result
page?a=1¬=3

The browser reads &not without a semicolon as an old entity name and turns it into a not sign. Text with a bare ampersand before letters like these can change when you decode it.

Run through the tool’s own code.

Text that was encoded twice

You enter
Direction
Decode HTML
Text
&amp;lt;
You get
Result
&lt;

Each press of Convert undoes one layer. Press Convert on the result again to get the final < character.

Run through the tool’s own code.

When it helps

  • Show a code sample such as a div tag inside a web page or blog post without the browser treating it as real markup.
  • Read text that arrives full of &amp; and &quot; from an export, a feed or an old database.
  • Repair a string that was encoded twice by decoding it one layer at a time.
  • Preview how a snippet looks once encoded before you paste it into a template.

Limits to keep in mind

  • Encode changes only five characters: ampersand, less-than, greater-than, double quote and single quote (written as &#39;). Accented letters, the euro sign and other non-ASCII characters stay as they are.
  • Decode uses the browser's own HTML reader. It knows named, decimal and hexadecimal entities and some old names that work without a semicolon, so text that only looks like an entity can change.
  • One pass at a time: &amp;lt; becomes &lt; and not <. Convert again for text that was encoded twice.
  • Escaping text for display is only one step. It does not make untrusted content safe in every place, for example inside a script or a web address.

Tips

  • Encode only once. Text that already contains &amp; becomes &amp;amp;, which then shows the wrong characters on the page.
  • When you decode a web address or query string, read the result closely, because pieces such as &not or &copy can change by themselves.
  • Both kinds of quote mark are encoded, so the result can also sit inside an HTML attribute value wrapped in either kind of quote.

Sources

Common questions

About HTML Entity Encoder & Decoder.

Why encode HTML special characters?

Characters like < and & mean something to a browser. If you want them to appear as text, you write them as entities. Encoding stops a snippet such as a tag from being read as real markup.

Can I turn HTML entities back into text?

Yes. Choose Decode HTML, paste the entities and press Convert. Names such as &eacute;, decimal codes such as &#65; and hexadecimal codes such as &#x41; all become their characters.

Which characters does Encode change?

Five: the ampersand, the less-than and greater-than signs, the double quote and the single quote. Everything else, including letters with accents and symbols like the euro sign, is left exactly as you typed it.

Why did my text change when I decoded it?

The browser also accepts some older entity names without a semicolon. Text such as ?a=1&not=3 contains &not, which turns into a not sign. If the text is a web address, do not decode it, or encode its ampersands first.

What happens if I decode text twice?

Each decode removes one layer. &amp;lt; becomes &lt; after the first press and < after the second. Decode again only when you know the text was encoded more than once.

Does the tool run or clean my HTML?

No. In a test, tags in the decoded result stayed as plain text. The tool also does not remove scripts or check markup, so do not treat it as a safety filter for untrusted content.

Is my text sent anywhere?

No. The page states that the conversion runs only in your browser, and the text is not sent to a server, so you can paste private snippets.