Encode and decode HTML entities
HTML reserves a few characters: < and > start and end tags, & starts an entity, and quotes delimit attributes. To show them as text, they must be written as entities.
Encoding modes
| Mode | “Café & ” becomes |
|---|---|
| Only < > & " ' | Café & <b>, the safe minimum for UTF-8 pages |
| Non-ASCII (named) | Café & <b>, for systems that only accept ASCII |
| Everything named | named entities wherever HTML5 defines one |
| Numeric references | Café & <b>, works everywhere, including XML |
Decoding understands all 2,231 named entities in the HTML5 specification ( , —, ♥…), decimal (é) and hexadecimal (é) references, including emoji like 😀.
Modern pages served as UTF-8 only need the minimal mode; the others exist for legacy systems, email templates and XML.
Worked example
Here is what the HTML Entity Encoder/Decoder returns for its built-in example. Settings used: Direction: Encode; Encode: Only < > & " '. Click Try an example in the tool above to load it, then change it as you like.
Café & “quotes” <b>bold</b> — 5 > 3 😀Café & “quotes” <b>bold</b> — 5 > 3 😀Questions
How do I escape HTML characters?
Choose Encode with the first option. The five reserved characters (less-than, greater-than, ampersand and both quote marks) are replaced with entities.
What does mean?
A non-breaking space: a space that prevents a line break between two words.
Last reviewed · How Textkiln tools work