Skip to content

HTML Entity Encoder and Decoder

Escape text for HTML (& < > " ') or decode HTML entities such as &amp;, &eacute; and &#x1F600; back to characters, with the full WHATWG name table.

Runs in your browser

Everything happens on your device: nothing you paste or type is sent to our server or stored. A share link holds your settings, and your input only if you choose to include it.

Minimal is all a UTF-8 page needs. Encode non-ASCII characters only for an ASCII-only file, email or system.

42 characters · 48 bytes (UTF-8) · limit 5 MB

Output: 71 characters.

Input length (characters)
42
Output length (characters)
71

Method: HTML character references, WHATWG HTML §13.1.4 · FindMySum codec (no library)

Off by default. When on, your input is packed into the part of the link after “#”, which browsers never send to any server; anyone you give the link to will see it.

How it works

Encoding replaces the five characters that can change the meaning of HTML with character references: & becomes &amp;, < becomes &lt;, > becomes &gt;, the double quote becomes &quot; and the apostrophe becomes &#39; (or &#x27; in hex). That minimal set is what the HTML standard requires for text and quoted attribute values in a UTF-8 page. You can also turn every non-ASCII character into a reference, either as a number (é becomes &#233;) or by name where the WHATWG table has one (é becomes &eacute;, ✓ becomes &check;).

Decoding follows the parsing rules in the WHATWG HTML Living Standard. All 2,231 named references are recognised, including ones that stand for two code points. Numeric references get the same replacements a browser makes: &#0;, surrogates and values beyond U+10FFFF become U+FFFD, and the values 128–159 map through the Windows-1252 table, so &#128; is the euro sign. Old names without a closing semicolon, such as &copy, are decoded the way browsers do in page text, with a warning; in attribute mode a name followed by = or a letter is left alone, as it is inside a link.

Everything runs in your browser. The full name table comes from the open-source entities library (version 9.0.0), which loads a moment after the page; the common references work before it arrives. Nothing you paste is uploaded.

Standards this tool follows

HTML Entity Encoder and Decoder: Escaping Text for HTML

By FindMySum · Last reviewed

An HTML entity encoder turns characters that HTML treats as markup into character references, so <b> appears on the page as text instead of making the following words bold. Paste text above to escape it, or switch to decode to turn &lt;, &eacute; and &#x1F600; back into the characters they stand for. Both directions run in your browser as you type.

When you need it

You need escaping whenever text that might contain < or & goes into HTML: a code sample in a blog post, a product description pulled from a spreadsheet, a comment typed by a visitor, or a value inserted into an attribute. Decoding is the reverse chore: reading an RSS feed, a database export or an email template where every quote and accent has been turned into an entity, and getting plain text back.

How to use the tool

  1. Choose encode or decode.
  2. When encoding, keep the first option, which escapes only & < > " ', for ordinary web pages. Pick the non-ASCII options when the output has to be pure ASCII, for example in an old email system or a file with an unknown character set.
  3. Choose decimal or hexadecimal for numeric references; both mean the same thing to a browser.
  4. When decoding something taken from inside an attribute, such as a link's href, open More options and choose attribute mode so legacy names are read the way a browser reads them there.

A worked example

The snippet <p class="note">Fish & chips</p> contains four characters that need escaping: two angle brackets in each tag, the quotes around note and the ampersand. Minimal encoding gives &lt;p class=&quot;note&quot;&gt;Fish &amp; chips&lt;/p&gt;, which a browser shows exactly as the original text. Decoding that string gives back the original snippet, character for character.

Common mistakes

Escaping the ampersand last. If code replaces < with &lt; first and then replaces every & with &amp;, the result is &amp;lt;. The ampersand has to be handled first, or in one pass as this tool does.

Relying on entities for security in the wrong place. Escaped text is safe between tags and inside quoted attributes, but not inside JavaScript, CSS or a javascript: link. Those contexts need different encoding.

Forgetting the semicolon. &copy 2026 happens to display as © 2026 because of rules kept for old pages, but &copy=1 inside a link stays as typed. Always end references with ;.

For other encodings, see the URL encoder and decoder for percent-escapes in links and the Base64 decoder for binary data written as text.

Sources

Frequently Asked Questions

Which characters must be escaped in HTML?

In normal page text, & and < are the ones that matter, and > is escaped by convention. Inside an attribute value wrapped in double quotes you also need &quot;, and inside single quotes the apostrophe. Escaping those five everywhere is the simple, safe rule this tool's minimal mode follows.

Should I use named or numeric entities?

Either works in every modern browser. Named references such as &copy; are easier to read in source code; numeric ones such as &#169; cover every character, including the many that have no name. On a page saved as UTF-8 you rarely need either for accented letters or emoji: type the character itself.

Does HTML-escaping make user input safe?

It prevents text from being read as markup when you place it in HTML text or a quoted attribute, which is the main defence against cross-site scripting there. It is not enough inside a script block, a style block, an unquoted attribute or a URL such as href, which each need their own encoding. Use your template engine's auto-escaping where you can.

Why does my page show &amp;amp; or &amp;lt;?

The text was escaped twice: once by your code and once by a template or library that escapes for you. Remove one of the two steps. This decoder warns when its output still contains entities, and the Swap button lets you decode a second time.

Spotted a wrong result or a bug? Report a problem (the link sends the page address only, never what you entered).

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy