HTML Entity Encoder Decoder
Convert special characters to HTML entities and back. Supports all named and numeric entities.
- Home
- > Encoder & Decoder >
- HTML Entity Encoder & Decoder
Encode
Decode
What is HTML Entity Encoding?
HTML entity encoding is the process of replacing special characters in HTML with their corresponding entity references. This prevents browsers from interpreting these characters as HTML markup and ensures your content displays correctly.
For example, the < character is encoded as <, and the & character is encoded as &. Without encoding, these characters would be interpreted as HTML tags or entity delimiters instead of literal text.
When Should You Use HTML Entity Encoding?
- Displaying code snippets in web pages (e.g., <div> instead of rendering a div)
- Showing special characters like &, <, > literally
- Preventing XSS (Cross-Site Scripting) attacks by sanitizing user input
- Including special characters in HTML attributes (e.g., title attributes)
- Ensuring valid HTML when using characters reserved for markup
How to Use This HTML Entity Encoder/Decoder
- Encode text — Type or paste HTML code into the left panel, then click Encode to convert special characters to HTML entities.
- Decode text — Type or paste HTML entities into the right panel, then click Decode to convert them back to regular characters.
- Copy the result — Use the copy button on each output field to grab the result for use in your project.
- Clear individual fields — Use the Clear button on each panel to reset the input and output.
Common HTML Entity Reference
| Character | Named Entity | Numeric Entity | Description |
|---|---|---|---|
| & | & | & | Ampersand |
| < | < | < | Less than |
| > | > | > | Greater than |
| " | " | " | Double quote |
| ' | ' | ' | Single quote / apostrophe |
| |   | Non-breaking space | |
| © | © | © | Copyright |
| ® | ® | ® | Registered trademark |
| ™ | ™ | ™ | Trademark |
| € | € | € | Euro |
| £ | £ | £ | Pound |
| ¥ | ¥ | ¥ | Yen |
| ¢ | ¢ | ¢ | Cent |
| § | § | § | Section |
| ¶ | ¶ | ¶ | Paragraph |
| — | — | — | Em dash |
| – | – | – | En dash |
| … | … | … | Ellipsis |
| « | « | « | Left angle quote |
| » | » | » | Right angle quote |
| × | × | × | Multiplication |
| ÷ | ÷ | ÷ | Division |
| ± | ± | ± | Plus-minus |
| µ | µ | µ | Micro |
Use Cases
- Code display on blogs & tutorials — When showing HTML, CSS, or JavaScript code in web pages, encode the code to prevent the browser from executing it.
- XSS prevention — Always encode user-generated content before rendering it in HTML to prevent cross-site scripting attacks.
- Email templates — HTML emails require proper entity encoding to ensure special characters render correctly across email clients.
- XML/JSON data — Encode HTML entities within XML or JSON strings to maintain valid data structures.
- Debugging — Decode entity-encoded strings to inspect the original content when debugging web applications.
Frequently Asked Questions
What is the difference between HTML encoding and URL encoding?
HTML encoding converts characters to &name; or &#NN; format for safe display in web pages. URL encoding uses %XX percent-encoding for safe transmission in URLs. They serve different purposes and use different encoding schemes.
Should I encode all special characters or just the basic ones?
For most use cases, encoding the five essential characters (&, <, >, ", ') is sufficient. This tool encodes all characters that have named HTML entities for maximum compatibility.
What is the difference between named and numeric entities?
Named entities use memorable names like © for ©, while numeric entities use the character's Unicode code point like ©. Browsers render both identically. Named entities are easier to remember for common characters, while numeric entities can represent any Unicode character.
Is HTML entity encoding the same as HTML escaping?
Yes, these terms are used interchangeably. Both refer to replacing special HTML characters with their entity references to prevent them from being interpreted as markup.
Does this tool work with all HTML entities?
Yes! This tool supports all named HTML entities (like ©, ™, €), numeric decimal entities (©), and numeric hex entities (©). Both encoding and decoding work bidirectionally.