UtilDojo

Popular

Menu

HTML Entity Encode & Decode Online

  • This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.

Text or HTML

Encoded

Result appears here.

About this tool

Encode converts the characters that break markup — & < > " and ' — into entities such as &amp; and &lt;, so text can be shown safely inside an HTML page or attribute. You can also encode every non-ASCII character, using a name like &copy; where one exists and a numeric reference otherwise.

For example, Tom & Jerry <b>"hi"</b> 'x' becomes Tom &amp; Jerry &lt;b&gt;&quot;hi&quot;&lt;/b&gt; &#39;x&#39;. With the non-ASCII option on, ₹ 5 © é becomes &#8377; 5 &copy; &eacute;, because the rupee sign has no short name in the table and so gets a number.

Decode turns named entities (&eacute;, &mdash;, &nbsp;), decimal references (&#8377;) and hex references (&#x20B9;) back into ordinary text. Unknown names such as &bogus; are left as they are rather than guessed. A common surprise is double escaping: text that already says &amp;lt; decodes once to &lt; and not to <, so decode again if you want the original.

Use it to prepare a code snippet for a blog post, to clean text copied from an email or CMS export, or to read an HTML source that is full of &#8217; and &amp;. Remember that encoding for the page body is not the same as encoding for a URL or JavaScript string; for those use the URL Encoder / Decoder or the String Escape / Unescape tool. The tool works entirely in your browser with no uploads.

Frequently asked questions

Does encoding protect against XSS?

Escaping text before inserting it into HTML is a key part of preventing cross-site scripting, but the right escaping depends on the context (HTML body, attribute, URL, script). Use your framework's built-in escaping where you can.

What is the difference between &#39; and &apos;?

Both mean an apostrophe. &#39; works in every HTML version, which is why it is used for encoding; &apos; is not recognised by very old HTML 4 parsers.

Which named entities can it decode?

The common ones — punctuation, currency, arrows, Greek letters and accented Latin letters. Any numeric reference decodes regardless of whether it has a name.

What is &nbsp;?

A non-breaking space. It looks like a space but stops a line from wrapping there. Decoding turns it into that character, which can cause surprises when you search for a normal space.

Why did my text not change when I encoded it?

Plain letters and digits do not need escaping. Only & < > " and ' are encoded by default, so text without those looks the same unless you choose to encode non-ASCII characters too.

Related tools