About this tool
This HTML entity encoder and decoder converts special characters into HTML character references and back, live, in both directions. Type or paste HTML or text on the left and the escaped version appears on the right; paste entity-laden markup on the right and the readable text appears on the left. You choose named entities (é), decimal (é), or hexadecimal (é) output, and whether to escape only the five characters that break HTML (& < > and both quotes) or every character outside plain ASCII as well. A filterable reference lists about 150 named entities with their numeric equivalents. It is for web developers escaping user content or code samples, writers pasting into CMS fields that mangle Unicode, and anyone debugging text that arrived full of ' and .
How it works
Encoding walks the text one Unicode code point at a time (so emoji and other astral characters become a single reference such as 😀 rather than two surrogate halves). The characters & < > and the double quote always become & < > "; the apostrophe becomes ' because ' was not part of HTML 4. With the non-ASCII option on, every code point above 127 is written as its named entity if one is in the built-in table of roughly 150 common names (Latin-1, punctuation, currency, arrows, Greek, math), otherwise as a numeric reference. Decoding matches &name; &#decimal; and &#xhex; references, tolerates a missing semicolon on the legacy names browsers accept without one (amp, lt, gt, quot, apos, nbsp, copy, reg), and remaps numeric references 128 to 159 to their Windows-1252 characters as the HTML standard requires. Unknown names are left untouched.
Frequently asked questions
Should I use ' or ' for an apostrophe?
' was not defined in HTML 4, so older browsers, notably Internet Explorer 8 and earlier, rendered it literally. HTML5 does define it, but ' has always worked everywhere, which is why this tool emits ' in named mode. In XML and XHTML both forms are valid.
Which characters must be escaped in HTML?
The ampersand must always be written as & in text and attribute values. The less-than sign must be escaped as < in text and should be in attributes too; the greater-than sign is escaped by convention. Inside a double-quoted attribute escape the double quote as ", and inside a single-quoted attribute escape the apostrophe as '. Non-ASCII characters do not need escaping as long as the page is served as UTF-8.
What is the difference between named, decimal, and hex entities?
They are three spellings of the same character: é, é, and é all render as é. Named entities are readable but only about 2,200 exist, and the less common ones need an HTML5 parser. Numeric references work for every Unicode code point in any HTML or XML parser, so they are the safer choice for machine-generated markup and for XML, which knows only five names.
Why does decode to an en dash instead of a control character?
Code points 128 to 159 are C1 control characters with no printable form, but documents created on Windows often use those numbers meaning the Windows-1252 characters at the same positions. The HTML standard therefore tells browsers to remap them: becomes the en dash (U+2013), becomes the trademark sign, becomes the euro sign, and so on. This tool applies the same table.