HTML Entity Encoder / Decoder
Convert special characters to HTML entities and back
Using named entities like < >
Only encoding special HTML characters
Common HTML Entities Reference:
| Character | Named Entity | Numeric Entity |
|---|---|---|
| & | & | & |
| < | < | < |
| > | > | > |
| " | " | " |
| ' | ' | ' |
| (space) | |   |
| © | © | © |
| ® | ® | ® |
| ™ | ™ | ™ |
| € | € | € |
| £ | £ | £ |
| — | — | — |
What are HTML Entities?
HTML entities are special codes used to display characters that have special meaning in HTML or characters that cannot be easily typed on a keyboard. They begin with an ampersand (&) and end with a semicolon (;). For example, the less-than sign (<) is written as < to prevent browsers from interpreting it as the start of an HTML tag.
Why Use HTML Entities?
- Reserved Characters: Characters like <, >, &, and " have special meaning in HTML. Using entities prevents parsing errors and security vulnerabilities.
- Special Symbols: Display symbols like copyright, trademark, or currency symbols that may not be available on all keyboards.
- Character Encoding: Ensure proper display of characters across different browsers and systems, regardless of the document encoding.
- Security: Prevent XSS (Cross-Site Scripting) attacks by encoding user input before displaying it in HTML.
Named vs Numeric Entities
HTML entities come in two formats:
- Named Entities: Use memorable names like
©for the copyright symbol. These are easier to read but not all characters have named entities. - Numeric Entities: Use the Unicode code point in decimal or hexadecimal format. These work for any Unicode character.
Essential HTML Entities
The most important entities to know are: < for less-than (<), > for greater-than (>), & for ampersand (&), " for double quotes ("), and ' for apostrophe (').
Tip: Always encode user-generated content before inserting it into HTML to prevent XSS vulnerabilities.