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 <, é and 😀 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
- Choose encode or decode.
- 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. - Choose decimal or hexadecimal for numeric references; both mean the same thing to a browser.
- 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 <p class="note">Fish & chips</p>, 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 < first and then replaces every & with &, the result is &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. © 2026 happens to display as © 2026 because of rules kept for old pages, but ©=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.