HTML Entity Encoder & Decoder: Quick Reference Guide
HTML entities are a fundamental part of web development that every developer encounters. They're how you display reserved characters (<, >, &, ") in HTML without breaking the page structure. A good HTML entity encoder/decodermakes working with these characters effortless.
What Are HTML Entities?
HTML entities are codes that represent special characters. They always start with &and end with ;. There are two types:
- Named entities:
<for <,>for > - Numeric entities:
<for <,>for >
When You Need to Encode HTML
User-Generated Content
If your app accepts user input and displays it on a web page, you mustHTML-encode that content. Failure to do so creates cross-site scripting (XSS) vulnerabilities. A user could submit <script>...</script>that executes on your site.
Code Examples in Blog Posts
When showing HTML code in a blog post (like this one), you need to encode the angle brackets so they display as text rather than being interpreted as HTML tags.
Email Templates
HTML email clients require encoding for special characters. Many email rendering engines are stricter than browsers about unescaped characters.
XML and RSS Feeds
XML uses the same encoding rules as HTML. Any content that contains <, >, or & must be encoded.
Common HTML Entities Reference
| Character | Named Entity | Numeric Entity |
|---|---|---|
| < (less than) | < | < |
| > (greater than) | > | > |
| & (ampersand) | & | & |
| " (double quote) | " | " |
| ' (single quote) | ' | ' |
| © (copyright) | © | © |
| ® (registered) | ® | ® |
| (non-breaking space) | |   |
| — (em dash) | — | — |
| … (ellipsis) | … | … |
Using an HTML Entity Encoder/Decoder
Rather than memorizing every entity code, use an HTML entity encoder and decoder tool. Paste in your text, click encode, and all special characters are converted to their entity equivalents instantly. The decoder does the reverse — turn encoded text back into readable characters.
For related developer utilities, check out our JSON formatterfor formatting API data that may contain HTML content.
Encoding in Practice
Most modern frameworks (React, Vue, Angular) handle HTML entity encoding automatically when you use templates properly. However, when you're working with raw HTML strings, inserting content via innerHTML, or building email templates manually, you still need to encode explicitly.