HTML Entity Converter: What Every Web Developer Should Know
Special characters breaking your HTML? Learn how HTML entities work, when to use them, and how to encode and decode like a professional web developer.
The Problem: Special Characters in HTML
You're writing an HTML page and need to display a less-than sign (<) or an ampersand (&). But when you type them directly, they break your markup. The browser interprets them as HTML syntax instead of content.
This is where HTML entities come in. An HTML entity is a special code that represents a character that can't be typed directly in HTML. Entities start with an ampersand (&) and end with a semicolon (;). For example, `<` displays as < and `&` displays as &.
Why HTML Entities Exist
HTML uses specific characters for its syntax. Angle brackets (< >) define tags. Ampersands (&) start entities. Quotes (" ') define attribute values. When you want to display these characters as text, you need to use their entity equivalents.
Without entities, your content breaks. A blog post about "5 < 10" would confuse the browser. A product description with "AT&T" would display incorrectly. Entities solve this by providing safe alternatives for every special character.
The Five Essential HTML Entities
| Character | Entity | Why You Need It |
|-----------|--------|-----------------|
| < | < | Starts HTML tags |
| > | > | Ends HTML tags |
| & | & | Starts HTML entities |
| " | " | Delimits attribute values |
| ' | ' | Delimits attribute values |
These five cover 99% of your encoding needs. If you remember nothing else, remember to encode ampersands, angle brackets, and quotes when they appear in content.
Named vs Numeric Entities
HTML entities come in two flavors:
**Named entities:** `&`, `<`, `© — `. These are easier to read and remember. There are over 2,000 named entities in HTML5.
**Numeric entities:** `<`, `©`, `—`. These use Unicode code points and work for any character. Numeric entities can be decimal (<) or hexadecimal (<).
When both are available, named entities are preferred for readability. For characters without named entities, use numeric entities.
Common HTML Entities You'll Use Daily
| Display | Entity | Character |
|---------|--------|-----------|
| © | © | Copyright symbol |
| ® | ® | Registered trademark |
| ™ | ™ | Trademark symbol |
| — | — | Em dash |
| – | – | En dash |
| … | … | Ellipsis |
| | | Non-breaking space |
| • | • | Bullet point |
| ° | ° | Degree symbol |
| € | € | Euro currency |
| £ | £ | Pound currency |
| ¥ | ¥ | Yen currency |
When to Encode and When Not To
Always Encode:
Don't Encode:
Security: HTML Entities and XSS Prevention
HTML encoding is your first line of defense against cross-site scripting (XSS) attacks. When you encode user input before displaying it, you prevent attackers from injecting malicious scripts.
The rule is simple: never trust user input. Always encode before displaying. Most modern frameworks (React, Angular, Vue) do this automatically, but if you're building server-rendered pages or working with raw HTML, manual encoding is essential.
Decoding HTML Entities
Decoding is the reverse operation — converting entities back to their character equivalents. This is useful when:
Conclusion
HTML entities are a fundamental part of web development. Understanding when and how to encode special characters prevents display bugs, improves security, and ensures your content renders correctly everywhere.
Encode and decode HTML entities instantly with our free HTML Entity Converter at txt.tools. Handles all named and numeric entities in your browser.
Enjoyed this article?
Check out our free online tools at txt.tools to help you work faster and smarter.