HTML Entity Encoder and Decoder

A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call

Free HTML entity encoder and decoder. Escape <, >, & and quotes so text shows safely in HTML, or turn &amp;, &copy; and &#8364; back into normal characters.

Characters
0
Changed
0
Result

Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.

How to use the HTML entity encoder and decoder

  1. Choose Encode or Decode.
  2. Paste your text or HTML.
  3. For encoding, choose how much to escape: only the five characters that have special meaning in HTML, or also every character outside basic ASCII, such as é, £, © and emoji.
  4. Copy the result.

The tool shows how many characters changed. Everything runs in your browser.

What an HTML entity is

HTML uses some characters for its own structure. A < starts a tag, & starts an entity, and quotes surround attribute values. If you want those characters to appear as text on a page, you write them as entities instead:

Character Entity Why it needs escaping
& &amp; Starts every entity
< &lt; Starts a tag
> &gt; Ends a tag
" &quot; Ends a double-quoted attribute
' &#39; Ends a single-quoted attribute

An HTML entity can be written three ways, and browsers treat them all the same:

  • By name: &copy; for ©, &euro; for €.
  • By decimal number: &#169; for ©.
  • By hexadecimal number: &#xA9; for ©.

Named entities are easier to read; numeric ones work for every character in Unicode, including emoji: &#127838; is 🍞.

When to encode

Showing code on a web page. If you write a tutorial that shows <div class="menu">, the browser would treat it as a real tag and hide it. Encoding turns it into &lt;div class=&quot;menu&quot;&gt;, which displays exactly as typed.

Putting text into HTML attributes. A product name with a quote in it, such as 12" pizza, breaks alt="12" pizza". Encoded, it's safe: alt="12&quot; pizza".

Preventing broken pages and security problems. Any text that came from a user, such as a review, a comment or a name, must be escaped before it goes into HTML. Otherwise someone could type <script> and run code in other visitors' browsers, an attack called cross-site scripting (XSS). Most website frameworks escape automatically; this HTML entity encoder is useful when you're writing HTML by hand, in an email template or a CMS that doesn't.

Old systems that only accept ASCII. Some email tools, databases and feeds mangle accented letters and symbols. Choosing "Also every non-ASCII character" replaces each one with a numeric HTML entity, which survives any system that keeps plain ASCII intact.

You don't need to encode ordinary text for modern web pages saved as UTF-8: letters like é and symbols like £ can be written directly. Only the five special characters always need care.

When to decode

Reading escaped text. Exports from CMSs, RSS feeds, APIs and databases sometimes contain Tom &amp; Jerry&#39;s. Decoding turns it back into Tom & Jerry's so you can read it or use it elsewhere.

Double-encoded text. If you see &amp;amp; or text like &amp;lt;b&amp;gt; on a page, the text was encoded twice. Decode it once to see what's underneath, and fix the place where it was encoded the second time.

Copying text out of HTML source. When you copy a title or description from page source, entities come with it. Decoding gives you the clean text for a document or spreadsheet.

The decoder uses your browser's own HTML parser for each HTML entity, so it understands all of the more than 2,000 named entities in the HTML standard, not just the common ones. Anything that looks like an entity but isn't one, such as &madeup;, is left exactly as it was and listed so you can check it.

Encoding is not the same as URL encoding or Base64

These get confused often:

  • HTML entities make text safe inside HTML: & becomes &amp;.
  • URL encoding (percent-encoding) makes text safe inside a web address: a space becomes %20 and & becomes %26. Use the URL encoder and decoder for that.
  • Base64 turns any data, including images, into letters and numbers, for embedding in emails, data URIs or APIs. Use the Base64 encoder and decoder.

A link inside HTML can need two of these at once: the URL is percent-encoded, and then any & in it is written &amp; inside the href attribute. Browsers handle & in links leniently, but encoding it is correct.

Common named entities

Character Name Number
non-breaking space &nbsp; &#160;
© &copy; &#169;
® &reg; &#174;
™ &trade; &#8482;
€ &euro; &#8364;
£ &pound; &#163;
— (em dash) &mdash; &#8212;
– (en dash) &ndash; &#8211;
… &hellip; &#8230;
‘ ’ &lsquo; &rsquo; &#8216; &#8217;
“ ” &ldquo; &rdquo; &#8220; &#8221;
° &deg; &#176;
× &times; &#215;

&nbsp; deserves a special mention: it's a space that won't break across lines and won't be collapsed. It's useful between a number and its unit, such as "10 kg", but using lots of them for layout makes pages hard to maintain; use CSS for spacing instead.

To strip all the tags from HTML and keep only the readable text, use the HTML to text converter. To turn plain paragraphs into HTML, use the text to HTML converter. For data formats, the JSON formatter and the XML formatter show escaped characters in context.

Entities in emails, CMSs and feeds

Email templates are one of the most common places where escaping goes wrong. Many email builders accept raw HTML, and a stray ampersand in a product name or a link can break the layout in some email clients. Running the text through an HTML entity encoder before pasting it into the template avoids that. The same applies to content management systems that let you edit HTML directly, and to RSS and product feeds, where an unescaped & makes the whole feed invalid.

Going the other way, text exported from a CMS or copied from page source often arrives full of entities. Decoding it before you paste it into a document, a spreadsheet or a social post keeps it readable. Each HTML entity is decoded exactly as a browser would display it.

Escaping in code

If you're writing code, use your language's built-in escaping rather than doing it by hand: most template systems, such as React, Vue, Django and Laravel's Blade, escape text automatically. This tool is for the places where that doesn't happen, and for checking what escaped text really says.

A worked example

A bakery's website shows its menu from a spreadsheet, and the developer writes the HTML by hand. One item is called Tom & Jerry's "Big" Breakfast Bun <new>. Pasted straight into the page, the <new> vanishes, because the browser reads it as an unknown tag, and the alt text on the photo breaks at the first quote.

She pastes the name into the HTML entity encoder with "Only the 5 special characters" selected. The result is Tom &amp; Jerry&#39;s &quot;Big&quot; Breakfast Bun &lt;new&gt;, with 6 characters changed. She uses it both in the menu text and in the image's alt attribute. The page now shows the name exactly as written, quotes and all.

Later, the same item comes back from the shop's API as Tom &amp;amp; Jerry&amp;#39;s. She decodes it once and sees Tom &amp; Jerry&#39;s: still encoded, so it was encoded twice. She finds the second encoding step in the import script and removes it.

Need more customers from Google?

This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. That is the whole job of DeepRit: a PPC-only agency that sets up and runs Google Ads accounts so every click is accounted for. You keep full ownership of your account, get a written report every week, and can stop at any time. See our pricing or ask for a free audit.

Frequently asked questions

What is an HTML entity?

An HTML entity is a code that stands for a character, such as &amp; for & or &copy; for ©. It lets you show characters that HTML would otherwise treat as code.

Which characters must be escaped in HTML?

Five: &, <, >, " and '. The ampersand and the less-than sign matter everywhere; quotes matter inside attribute values.

How do I decode HTML entities?

Choose Decode, paste the text, and copy the result. The tool uses your browser's HTML parser, so every named and numeric entity is decoded correctly.

Is this the same as URL encoding?

No. HTML entities make text safe inside HTML; URL encoding makes text safe inside a web address, using % codes.

Do I need to encode accented letters?

Not on modern UTF-8 pages. Encode them only for systems that can't handle non-ASCII text, using the "every non-ASCII character" option.

Is this HTML entity encoder free?

Yes. It's free, needs no sign-up, and runs in your browser.

Free PPC audit

See where your ad budget leaks.

We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.

Book a free audit call 30-minute call · Free · The audit is yours to keep