DevCalcHub

HTML Entity Encoder & Decoder

Use this HTML entity encoder to escape special characters like <, >, & and quotes so they display as text in HTML, or decode HTML entities back to plain characters.

By DevCalcHub Editorial Team · Last updated:

How it works

Encoding replaces characters that have special meaning in HTML (&, <, >, ", ') with their named entity equivalents so they display as literal text rather than being interpreted as markup.

Decoding reverses this, supporting both named entities (&amp;) and numeric entities (&#38; or &#x26;).

Example

Encoding a string with HTML-significant characters:

Input: Tom & Jerry's <great> day
Output: Tom &amp; Jerry&#39;s &lt;great&gt; day

How to use the HTML entity encoder

  • Paste your text or HTML.
  • Choose Encode to escape &, <, >, " and ', or Decode to turn entities back into characters.
  • Copy the output into your HTML.

When decoding, the tool supports &amp;, &lt;, &gt;, &quot;, &apos;, &#39; and &nbsp; by name, plus any numeric entity such as &#169; or &#x20B9;.

Common HTML entities

CharacterNamed entityNumeric entity
&&amp;&#38;
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&apos;&#39;
Non-breaking space&nbsp;&#160;
©&copy;&#169;
®&reg;&#174;
™&trade;&#8482;
₹ (Indian rupee)—&#8377;
€&euro;&#8364;
— (em dash)&mdash;&#8212;

When you need to escape HTML

  • Showing code samples on a web page — otherwise the browser renders the tags instead of showing them.
  • Inserting user-provided text into HTML, as a basic defence against HTML and script injection (XSS).
  • Putting quotes inside HTML attribute values.

Modern frameworks such as React escape text automatically, so you mostly need this for templates, emails and static HTML. To make text safe inside a URL instead, use the URL Encoder.

Frequently asked questions

Why do I need to encode HTML entities?

If you're inserting user-provided or special-character text into HTML, encoding prevents characters like < and > from being misinterpreted as tags — which both breaks your page's structure and, in dynamic contexts, is a basic defense against HTML/script injection.

What's the difference between named and numeric entities?

Named entities like &amp; are more readable; numeric entities like &#38; or &#x26; represent a character by its Unicode code point and can encode any character, not just the handful with dedicated names.

What is &nbsp;?

&nbsp; is a non-breaking space — a space that browsers won't collapse or break a line at. It is useful for keeping things like "10 km" or "₹ 500" together on one line.

What is the HTML code for the rupee symbol?

There is no named entity for ₹; use the numeric entity &#8377; (or &#x20B9;), or simply type ₹ in a UTF-8 page.

What is the difference between HTML encoding and URL encoding?

HTML encoding makes characters safe to display inside HTML (for example < becomes &lt;). URL encoding makes characters safe inside a URL (for example a space becomes %20). They are used in different places and are not interchangeable.

Related tools

Input

Output

&lt;p class=&quot;example&quot;&gt;Tom &amp; Jerry&#39;s &quot;great&quot; day&lt;/p&gt;