HTML Entity Encoder / Decoder
Escape text for safe use in HTML (< → <) or decode any named, decimal or hex entity back to readable characters.
Escaped HTML
Output will appear here…What this tool does
HTML treats <, >, & and quotes as part of its syntax. When you want those characters to appear as text — a code sample in a blog post, a product name like "Fish & Chips", user input echoed back in a template — they must be written as entities such as < and &.
The Encode mode produces that escaped text. The Decode mode does the reverse: it turnsé, é or é back into é. It is useful when you scrape HTML, read an RSS feed, or receive API data that was escaped twice and shows up as &quot;.
How to use it
- Pick Encode or Decode.
- Paste your text in the input box, or click Example to try a sample.
- In Encode mode, choose how Non-ASCII characters are handled (keep, hex or decimal) and whether to Also escape backtick.
- Read the result in the output panel and click Copy. Swap & flip mode sends the output back as input to check the round trip.
- Need a single symbol? Use the Common entities list and its Copy buttons.
Worked example
Encoding this snippet with the default options:
Input: <a href="/search?q=fish&chips">Tom's café</a> Output: <a href="/search?q=fish&chips">Tom's café</a> Hex: <a href="/search?q=fish&chips">Tom's café</a>
Decoding a string that mixes named, hex and decimal references:
Input: <p>Café & crème — ½ price 😀 ✓</p> Output: <p>Café & crème — ½ price 😀 ✓</p>
Options explained
- Base escaping (always on):
&→&,<→<,>→>,"→",'→'. This set is safe both in element content and inside quoted attribute values. - Non-ASCII characters: Keep as-is is right for UTF-8 pages. Hex and Decimal turn every character above code point 127 (accents, symbols, emoji) into a numeric reference, so the output is pure ASCII.
- Also escape backtick writes
`as`, handy when the HTML ends up inside a JavaScript template literal. - Decode has no options: it follows the HTML5 parsing rules exactly as a browser does.
Limitations
Encoding is context-free. It makes text safe in HTML element content and quoted attributes, but it is not enough inside<script> blocks, inline event handlers, CSS or unquoted attributes — those contexts need their own escaping. Because decoding follows browser rules, a few legacy names are recognised even without the trailing semicolon (for example©), exactly as in a real page. The encoder never produces named entities other than the base five; numeric references are used instead because every parser understands them.
Tips and common mistakes
- Double escaping: if you see
&lt;on a page, the text was escaped twice. Decode it twice, then fix the code path that escapes it a second time. - Frameworks already escape: React, Vue and Angular escape interpolated text for you. Manual escaping is needed with
innerHTML, string-built templates and email HTML. - Escaping is not sanitising: to allow some HTML (bold, links) while blocking scripts, use a sanitiser such as DOMPurify instead of entity encoding.
- Putting the text in a URL instead? Use the URL encoder. To see exactly which code points a string contains, try the Unicode inspector.
Frequently Asked Questions
Why should I encode HTML entities?
Characters like <, > and & have a structural meaning in HTML. Escaping them makes the browser display them as text instead of parsing them as markup, which is the core defence against cross-site scripting (XSS) when you insert untrusted text into a page.
What is the difference between named and numeric entities?
Named entities use a mnemonic (©), decimal entities use the Unicode code point in base 10 (©) and hex entities use base 16 (©). All three produce the same character; numeric ones work for any character, named ones only for the roughly 2,000 names defined in HTML5.
Does the decoder support all HTML5 named entities?
Yes. Decoding is done by your browser's own HTML parser, so every named character reference in the HTML5 specification (such as ½, ✓ or ≂̸) is recognised, along with decimal and hex references.
What happens with an invalid reference like �?
Code points above U+10FFFF, surrogates and zero are not valid characters. The tool flags them and, like every browser, decodes them as the replacement character � instead of failing.
Do I need to encode accented letters and emoji?
Not if your page is served as UTF-8, which is the default for modern HTML. Use the "Non-ASCII characters" option only when the text must pass through a system that is limited to ASCII, such as some email templates or legacy databases.
Is my text sent to a server?
No. Encoding and decoding happen entirely in your browser. Decoding uses a detached textarea element, which interprets entities without creating any HTML elements or running scripts.
Related tools
- Base64 Encoder/DecoderEncode and decode Base64 strings online
- JWT Decoder & ValidatorDecode JSON Web Tokens (JWT) and inspect their header, payload, claims, and expiry status.
- URL Encoder / DecoderEncode or decode URLs and query string parameters using percent-encoding (RFC 3986).
- Image to Base64Convert images to Base64 encoded strings
- Base64 to Image DecoderDecode Base64 strings back to images. Preview the image live and download it as PNG, JPEG, or WebP.
- Base32 Encoder/DecoderEncode and decode Base32 strings online
Found a bug or a wrong result? Report it.