ToolNimba Browse

🔣 HTML Entity Encoder and Decoder

By ToolNimba Editorial Team · Updated 2026-06-19

Type some text and press Encode.

This HTML entity encoder and decoder converts text to safe HTML entities and back again. Encoding turns characters that have meaning in markup, such as the less-than sign, the ampersand, and quotation marks, into entities like < and & so a browser renders them as literal text rather than treating them as code. Decoding does the reverse, turning entities back into the characters they stand for. Everything runs in your browser, so the text you paste never leaves your device.

What is the HTML Entity Encoder?

HTML entities are short codes that represent a character without typing the character itself. They exist because a handful of characters are reserved: the browser reads a less-than sign as the start of a tag and an ampersand as the start of an entity. If you want those characters to appear on screen as ordinary text, you have to write them as entities instead, for example &lt; for < and &amp; for &. The same trick lets you include characters that are hard to type or that might not survive a particular file encoding, such as a copyright sign or an em dash.

Every entity comes in three forms. A named entity uses a memorable label, like &copy; for the copyright sign. A decimal numeric entity uses the character's Unicode code point in base ten, like &#169; for the same sign. A hexadecimal numeric entity uses the code point in base sixteen, like &#xA9;. All three produce the identical character. Named entities read more clearly but only a few hundred names exist, so numeric entities are the universal fallback for anything else, including emoji.

When you encode, you usually only need to escape the five characters that are special in HTML: the ampersand, the less-than and greater-than signs, and the two kinds of quotation mark. Encoding more than that is optional. This tool can also encode every non-ASCII character, which is handy when a system can only safely transmit plain ASCII. When you decode, the order matters: the ampersand must be turned back last, or you risk double-decoding. This tool uses the browser's own parser to decode, so all named, decimal, and hexadecimal entities resolve correctly in one pass.

When to use it

  • Displaying example HTML or code on a web page so the tags show as text instead of rendering.
  • Escaping user-supplied text before inserting it into a page, to help prevent broken layout and injection.
  • Cleaning up content pasted from a CMS or email where characters arrived as raw entities like &amp;amp;.
  • Encoding accented names or symbols into ASCII-safe entities for an older system or a strict data feed.

How to use the HTML Entity Encoder

  1. Choose Encode to turn text into entities, or Decode to turn entities back into text.
  2. Paste or type your content into the input box.
  3. For encoding, optionally tick "Encode all non-ASCII" and choose whether to prefer named entities.
  4. Read the result, then press Copy to put it on your clipboard. Use Swap to feed the result back as new input.

Formula & method

Encode: replace each reserved character with its entity, e.g. & → &amp;, < → &lt;, > → &gt;, " → &quot;, ' → &#39;. A numeric entity is &#N; (decimal) or &#xH; (hex) where N or H is the Unicode code point.

Worked examples

Showing a snippet of HTML as text: <a href="x">Go</a>

  1. Escape each reserved character left to right.
  2. < becomes &lt; and > becomes &gt;
  3. The double quotes become &quot;
  4. There is no & in the snippet, so nothing else changes.

Result: &lt;a href=&quot;x&quot;&gt;Go&lt;/a&gt;

Encoding "© 2026 Café" with non-ASCII encoding and named entities on.

  1. The copyright sign © is code point 169, which has the name &copy;
  2. The space and digits are plain ASCII, so they stay as they are.
  3. The é in Café is code point 233 (hex E9) with no common name, so it becomes &#xE9;

Result: &copy; 2026 Caf&#xE9;

Decoding 5 &gt; 3 &amp;&amp; 2 &lt; 4 back to plain text.

  1. &gt; resolves to >
  2. &lt; resolves to <
  3. Each &amp; resolves to a single &

Result: 5 > 3 && 2 < 4

The five reserved HTML characters and their entities

CharacterNamed entityDecimalHex
&&amp;&#38;&#x26;
<&lt;&#60;&#x3C;
>&gt;&#62;&#x3E;
"&quot;&#34;&#x22;
'&apos; or &#39;&#39;&#x27;

Common symbol entities

SymbolNamed entityDecimalHex
© copyright&copy;&#169;&#xA9;
® registered&reg;&#174;&#xAE;
™ trademark&trade;&#8482;&#x2122;
€ euro&euro;&#8364;&#x20AC;
£ pound&pound;&#163;&#xA3;
non-breaking space&nbsp;&#160;&#xA0;
— em dash&mdash;&#8212;&#x2014;

Common mistakes to avoid

  • Encoding the ampersand twice. If you encode text that already contains entities, &amp;copy; turns into &amp;amp;copy; and shows on the page as &copy; instead of the symbol. Decode first, or only encode raw text.
  • Using &apos; in old HTML. The named entity &apos; for the apostrophe is valid in XHTML and HTML5 but not in HTML4. For the widest compatibility, the numeric &#39; is safer, which is why this tool outputs &#39;.
  • Forgetting the trailing semicolon. An entity must end with a semicolon, like &amp;. Writing &amp without it may still render in some browsers but is technically invalid and can break parsing.
  • Relying on encoding alone for security. Escaping the five reserved characters helps prevent broken markup, but safe output depends on context (HTML body, attribute, URL, script). Use the right encoding for each context, not just one blanket pass.

Glossary

HTML entity
A code that represents a single character, written as an ampersand, a name or number, and a semicolon, such as &amp; or &#38;.
Named entity
An entity that uses a human-readable label, like &copy; or &nbsp;. Only a few hundred names exist.
Numeric entity
An entity that uses the character's Unicode code point, in decimal (&#169;) or hexadecimal (&#xA9;).
Reserved character
A character that has special meaning in HTML and must be escaped to appear as text: & < > " and '.
Code point
The numeric identifier Unicode assigns to a character, for example 169 for the copyright sign.

Frequently asked questions

What does an HTML entity encoder do?

It converts characters that have special meaning in HTML, such as <, >, &, and quotes, into entity codes like &lt; and &amp; so they display as literal text instead of being read as markup. It can also turn entities back into plain characters.

Which characters must I escape in HTML?

Five characters are reserved: the ampersand (&), the less-than sign (<), the greater-than sign (>), the double quote ("), and the single quote ('). Escaping these covers most cases; other characters are optional.

What is the difference between named and numeric entities?

A named entity uses a label, like &copy;, while a numeric entity uses the character code, like &#169; (decimal) or &#xA9; (hex). They produce the same character; named entities are easier to read but limited in number.

How do I decode HTML entities back to text?

Switch this tool to Decode and paste the text. It resolves named, decimal, and hexadecimal entities in one pass using the browser parser, so &amp;copy; becomes © and &amp;amp; becomes a single ampersand.

Is it safe to paste sensitive text here?

Yes. All encoding and decoding happens locally in your browser with plain JavaScript. Nothing is uploaded, sent over the network, or stored, so the text never leaves your device.

Does this prevent cross-site scripting (XSS)?

Escaping the reserved characters reduces the risk of injected markup, but full protection depends on encoding for the correct context (HTML body, attribute, URL, or script) and other defenses. Treat this tool as one helpful step, not a complete security solution.