HTML Entities Encoder / Decoder Encode and decode a piece of text to its HTML equivalent
Description
The HTML character encoder converts all applicable characters to their corresponding HTML entities. Certain characters have special significance in HTML and should be converted to their correct HTML entities to preserve their meanings.
For example, it is not possible to use the < character as it is used in the HTML syntax to create and close tags. It must be converted to its corresponding < HTML entity to be displayed in the content of an HTML page. HTML entity names are case sensitive.
Reserved entities, symbols and characters in HTML
This table shows a list of reserved HTML entities with their associated character and description.
Character | Entity name | Description |
---|---|---|
" | " | quotation mark |
' | ' | apostrophe |
& | & | ampersand |
< | < | less-than |
> | > | greater-than |
| non-breaking space | |
¡ | ¡ | inverted exclamation mark |
¢ | ¢ | cent |
£ | £ | pound |
¤ | ¤ | currency |
¥ | ¥ | yen |
¦ | ¦ | broken vertical bar |
§ | § | section |
¨ | ¨ | spacing diaeresis |
© | © | copyright |
ª | ª | feminine ordinal indicator |
« | « | angle quotation mark (left) |
¬ | ¬ | negation |
| ­ | soft hyphen |
® | ® | registered trademark |
¯ | ¯ | spacing macron |
° | ° | degree |
± | ± | plus-or-minus |
² | ² | superscript 2 |
³ | ³ | superscript 3 |
´ | ´ | spacing acute |
µ | µ | micro |
¶ | ¶ | paragraph |
· | · | middle dot |
¸ | ¸ | spacing cedilla |
¹ | ¹ | superscript 1 |
º | º | masculine ordinal indicator |
» | » | angle quotation mark (right) |
¼ | ¼ | fraction 1/4 |
½ | ½ | fraction 1/2 |
¾ | ¾ | fraction 3/4 |
¿ | ¿ | inverted question mark |
× | × | multiplication |
÷ | ÷ | division |
À | À | capital a, grave accent |
Á | Á | capital a, acute accent |
 |  | capital a, circumflex accent |
à | à | capital a, tilde |
Ä | Ä | capital a, umlaut mark |
Å | Å | capital a, ring |
Æ | Æ | capital ae |
Ç | Ç | capital c, cedilla |
È | È | capital e, grave accent |
É | É | capital e, acute accent |
Ê | Ê | capital e, circumflex accent |
Ë | Ë | capital e, umlaut mark |
Ì | Ì | capital i, grave accent |
Í | Í | capital i, acute accent |
Î | Î | capital i, circumflex accent |
Ï | Ï | capital i, umlaut mark |
Ð | Ð | capital eth, Icelandic |
Ñ | Ñ | capital n, tilde |
Ò | Ò | capital o, grave accent |
Ó | Ó | capital o, acute accent |
Ô | Ô | capital o, circumflex accent |
Õ | Õ | capital o, tilde |
Ö | Ö | capital o, umlaut mark |
Ø | Ø | capital o, slash |
Ù | Ù | capital u, grave accent |
Ú | Ú | capital u, acute accent |
Û | Û | capital u, circumflex accent |
Ü | Ü | capital u, umlaut mark |
Ý | Ý | capital y, acute accent |
Þ | Þ | capital THORN, Icelandic |
ß | ß | small sharp s, German |
à | à | small a, grave accent |
á | á | small a, acute accent |
â | â | small a, circumflex accent |
ã | ã | small a, tilde |
ä | ä | small a, umlaut mark |
å | å | small a, ring |
æ | æ | small ae |
ç | ç | small c, cedilla |
è | è | small e, grave accent |
é | é | small e, acute accent |
ê | ê | small e, circumflex accent |
ë | ë | small e, umlaut mark |
ì | ì | small i, grave accent |
í | í | small i, acute accent |
î | î | small i, circumflex accent |
ï | ï | small i, umlaut mark |
ð | ð | small eth, Icelandic |
ñ | ñ | small n, tilde |
ò | ò | small o, grave accent |
ó | ó | small o, acute accent |
ô | ô | small o, circumflex accent |
õ | õ | small o, tilde |
ö | ö | small o, umlaut mark |
ø | ø | small o, slash |
ù | ù | small u, grave accent |
ú | ú | small u, acute accent |
û | û | small u, circumflex accent |
ü | ü | small u, umlaut mark |
ý | ý | small y, acute accent |
þ | þ | small thorn, Icelandic |
ÿ | ÿ | small y, umlaut mark |
Code samples
Most programming languages provide a way to convert HTML entities to their associated character and vice-versa.
htmlentities (PHP 4, PHP 5)
Convert all applicable characters to HTML entities.
string htmlentities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = true ]]] )
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.
If you're wanting to decode instead (the reverse) you can use html_entity_decode().
HttpUtility.HtmlEncode Method (String) .NET Framework 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Converts a string to an HTML-encoded string.
public static string HtmlEncode( string s )
HTML encoding converts characters that are not allowed in HTML into character-entity equivalents; HTML decoding reverses the encoding. For example, when embedded in a block of text, the characters < and > are encoded as < and > for HTTP transmission.