HTML Entities Encoder
Common HTML entities reference
| Character | Entity | Description |
|---|---|---|
| & | & | Ampersand |
| < | < | Less than |
| > | > | Greater than |
| " | " | Double quotes |
| ' | ' | Apostrophe |
| © | © | Copyright |
| ® | ® | Registered trademark |
| ™ | ™ | Trademark |
| € | € | Euro |
| £ | £ | Pound |
| ° | ° | Degree |
| (space) | | Non-breaking space |
| – | – | En dash |
| — | — | Em dash |
| … | … | Ellipsis |
| × | × | Multiplication |
Frequently Asked Questions
Everything you need to know about HTML entities
When is HTML encoding necessary?
HTML encoding is necessary when inserting user-generated content into an HTML page. Without encoding, characters like < > & " can be interpreted as HTML code, causing XSS (Cross-Site Scripting) vulnerabilities. It is essential in all templates that display untrusted data.
What is the difference between & and &?
& is a named entity, while & is a decimal numeric entity (and & is the hexadecimal one). They all represent the "&" character. Named entities are more readable, numeric ones are universally supported. Both are valid in HTML5.
Do I need to encode spaces in HTML?
Normal spaces do not require encoding in HTML. (Non-Breaking Space) is a special space that prevents word wrap and creates an incompressible space. It is used when you want to keep spaces between words that should not be separated on different lines.
Does HTML encoding protect against all XSS attacks?
HTML encoding of special characters is the first line of defense against XSS, but is not sufficient alone. You also need to: use Content Security Policy (CSP), validate input server-side, sanitize URLs (javascript:// is dangerous), and use frameworks that protect automatically (Laravel Blade with {{ }} escapes automatically).
What is the difference between the named and the numeric form?
The named form reads better, while the numeric one, in decimal or hexadecimal, is supported everywhere. They stand for the same character and the browser reads them in exactly the same way.
When does a character need encoding?
When it already means something in the markup, such as the angle brackets and the ampersand, and when you want to be sure a rare symbol shows up whatever the page encoding turns out to be.
Does a space need encoding?
An ordinary space does not. The non-breaking space entity is what you want when two words must not be split at the end of a line, for instance between a number and its unit of measure.