HTML Entity Encoder and Decoder

To show <, >, & and quotes as text in a web page, write them as HTML entities: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &#39;. Type text to encode it, or switch to Decode to turn named references like &copy; and numeric ones like &#8226; back into characters, by the rules of the HTML Standard.

Converted on your device. What you type goes into the page’s link (and your browser history), so don’t paste anything private.

HTML-encoded
&lt;p&gt;Tom &amp; Jerry&#39;s &quot;café&quot;&lt;/p&gt; Special characters

8 characters became references, so a web page shows “<p>Tom & Jerry's "café"</p>” as text instead of reading it as HTML.

Characters in 27
Replaced 8
Characters out 57

What are HTML entities?

In HTML, < starts a tag and & starts a character reference, so text that contains them has to write them another way. A character reference, often called an HTML entity, is an & followed by a name or a number and a semicolon. There are three kinds: named (&copy;), decimal (&#169;) and hexadecimal (&#xA9;). All three give ©.

Quotes need encoding inside attribute values, so " becomes &quot; and ' becomes &#39;. Other characters can be typed as they are in a UTF-8 page; encode them too only for systems that carry plain ASCII.

Source WHATWG HTML Standard · 13.1.4 Character references ↗

How to encode and decode HTML entities

& → &amp; < → &lt; > → &gt; " → &quot; ' → &#39;

Here it is with your numbers:

  1. “<” (U+003C) becomes &lt;, 2 times.
  2. “>” (U+003E) becomes &gt;, 2 times.
  3. “&” (U+0026) becomes &amp;.
  4. “'” (U+0027) becomes &#39;.
  5. “"” (U+0022) becomes &quot;, 2 times.

It means you can paste the result into HTML, and the page shows exactly what you typed.

Decoding works the other way, as a browser reads the page: it takes the longest name that matches, so &notin; is ∉ but &notit; is ¬ followed by “it;”. Numbers 128 – 159 become the characters the old windows-1252 code page put there (&#128; is €), and 0, numbers past 10FFFF and the surrogate range become �.

Source WHATWG HTML Standard · 13.2.5.72 Character reference state ↗

HTML entity examples

CharacterNamedDecimal
&&amp;&#38;
<&lt;&#60;
>&gt;&#62;
"&quot;&#34;
'&apos;&#39;
(no-break space)&nbsp;&#160;
©&copy;&#169;
™&trade;&#8482;
€&euro;&#8364;
–&ndash;&#8211;
—&mdash;&#8212;
…&hellip;&#8230;
•&bull;&#8226;

Which named references this tool decodes

The HTML Standard lists 2,231 names, too many for this page to carry and stay fast. The decoder knows the 259 HTML 4 names (accented and Greek letters, arrows, maths and typography signs) plus &apos; and the capital forms &AMP;, &LT;, &GT;, &QUOT;, &COPY; and &REG;. Every numeric reference works. Other names, like &check;, are left as typed and listed in the steps.

Source WHATWG HTML Standard · 13.5 Named character references ↗

FAQs

What is HTML entity encoding?

Writing a character as a character reference instead: an &, then a name or a number, then a semicolon, like &lt; for <. The browser shows the character as text, so < and & in your text can’t be mistaken for HTML code.

Source WHATWG HTML Standard · 13.1.4 Character references ↗

What is &#39 in HTML?

&#39; is the apostrophe ('): a decimal numeric reference to character 39. Written properly it ends in a semicolon, &#39;, though browsers also accept it without one.

What is &#8226 in HTML?

&#8226; is the bullet (•), character U+2022. Its named reference is &bull;.

Source WHATWG HTML Standard · 13.5 Named character references ↗

How can I decode HTML code?

Switch this tool to Decode and paste the text. Each &name; or &#number; becomes its character, using the same rules a browser follows, including the old forms without a semicolon.

Source WHATWG HTML Standard · 13.2.5.72 Character reference state ↗

What is %27 in HTML encoding?

%27 is URL (percent) encoding, not HTML: it is the apostrophe as byte 27 in hex, used in web addresses. In HTML the apostrophe is &#39; or &apos;. Use the URL Encoder and Decoder for %27.

Source RFC 3986 · Uniform Resource Identifier (URI): Generic Syntax, section 2.1 ↗

Sources

Related calculators