What HTML encoding is
In HTML, a few characters have a job. < starts a tag, & starts an entity, and quotes end an attribute value. To show those characters as plain text, for example to print a code sample on a web page, you write them as HTML entities instead. The browser displays the entity as the character and does not treat it as markup.
Common HTML entities
| Character | Named | Numeric | Meaning |
|---|---|---|---|
| & | & | & | Ampersand |
| < | < | < | Less than |
| > | > | > | Greater than |
| " | " | " | Double quote |
| ' | ' | ' | Apostrophe |
| No-break space | |   | Space that keeps words together |
| © | © | © | Copyright sign |
| € | € | € | Euro sign |
Numeric entities work for any Unicode character: é is é, written in decimal, and é is the same in hex.
Basic or all
Basic encodes the five characters that matter in HTML: & < > " and '. Everything else stays readable. All also turns every character outside plain ASCII into a numeric entity, and the slash into /, which helps when the text passes through a system that cannot handle UTF-8.
Decoding entities
Switch to HTML to Text to turn entities back into characters. The decoder understands named entities (é), decimal ones (é) and hex ones (é). It decodes one level at a time, so text that was encoded twice, such as &lt;, needs two passes.
Questions about HTML entities
Which characters must be encoded in HTML?
The ampersand & and the less-than sign < always matter, because they start entities and tags. Inside attribute values, quotes need encoding too. The greater-than sign > is encoded by convention. This tool encodes all five: & < > " and '.
What is the difference between & and &?
Nothing in the result. & is a named entity and & is a numeric entity for the same character, code 38. Named entities are easier to read; numeric ones work for any character.
Do I need to encode accented letters and emoji?
Not on a page saved as UTF-8, which nearly all are today. Choose All under Encode if your text goes somewhere that only handles plain ASCII; every non-ASCII character then becomes a numeric entity.
Does encoding HTML protect against XSS?
Encoding text before you put it into an HTML page is one of the main defenses against cross-site scripting, because a script tag becomes harmless text. It is not enough on its own inside JavaScript, URLs or CSS, which each need their own escaping.
Is my text sent to a server?
No. Encoding and decoding run in your browser with JavaScript, and nothing you paste leaves your device.