What HTML Entity Encoder & Decoder does
Five characters cannot be dropped into HTML as-is without changing what the markup means: the ampersand, the angle brackets and both quote marks. This tool escapes them into entities so the browser renders them as text rather than treating them as syntax, and decodes in the other direction when you need to read content that has already been escaped — sometimes escaped twice, which is where the confusing < sequences come from. Encoding runs in your browser, so you can safely paste content from a database or a user submission while you work out what is happening to it.
What people use it for
Showing code samples on a page
Displaying HTML markup as text requires escaping it first, otherwise the browser renders the example instead of showing it.
Tracking down double-encoded text
When users see & on a page, something escaped already-escaped text. Decoding step by step shows how many layers were applied.
Preparing content for an email template
Email clients are far less forgiving than browsers, and escaping unusual characters avoids layouts breaking in older desktop clients.
Cleaning up scraped or exported content
Text pulled out of a CMS or an RSS feed often arrives escaped. Decoding restores readable prose before you edit it.
Step by step
- 1
Choose whether you are encoding text into entities or decoding entities back into text.
- 2
Paste the text or markup into the input box.
- 3
For encoding, decide whether to escape only the HTML-unsafe characters or also every non-ASCII character.
- 4
Copy the result. When decoding, run it twice if the output still contains entities — that indicates double encoding.
Why the ampersand has to be escaped first
Every entity begins with an ampersand, which makes the ampersand itself the character that has to be handled before any other. If you escaped the angle brackets first and the ampersands afterwards, the ampersand that you just introduced at the start of < would be escaped in turn, producing &lt; — and the browser would then render the literal text < rather than a less-than sign. This ordering requirement is the mechanical reason double-encoded text is so common: any pipeline where one stage escapes and a later stage escapes again produces exactly this result, and each additional pass adds another amp; layer. When you see a page displaying &amp;quot;, you are looking at three passes. Decoding repeatedly until the output stops changing tells you how many stages in your pipeline are doing the work, which is usually one more than intended.
Named entities, numeric references, and when to use each
There are two ways to write any entity. A named reference such as © is readable but only works for characters that have an assigned name, and the set of valid names depends on the HTML version. A numeric reference such as © or its hexadecimal form © works for any character in Unicode and is understood everywhere, at the cost of being unreadable in source. The practical rule is that named entities are worth using for the handful you recognise on sight, and numeric references are the safe default for everything else. There is one specific trap: ' for the apostrophe is defined in XML and HTML5 but not in HTML 4, so ' is the safer choice in templates and email where the parsing mode is uncertain. For ordinary accented letters and emoji on a UTF-8 page, no escaping is needed at all — writing them literally is both correct and far easier to read.
Tips
- On a UTF-8 page, leave accented characters and emoji unescaped; the extended mode is for legacy systems with uncertain encoding.
- If decoded output still contains entities, decode again — each pass peels off one layer of encoding.
- Escaping is context-sensitive: text going into a URL, a script block or a CSS value needs its own escaping rules, not HTML entities.