HTML Entity Encoder & Decoder
Encode special characters to HTML entities or decode entities back to readable text. Supports named and numeric entities.
Quick Answer
The 5 essential HTML entities: & (ampersand), < (less than), > (greater than), " (double quote), ' (apostrophe).
Common HTML Entities Reference
| Character | Named | Numeric | Description |
|---|---|---|---|
| & | & | & | Ampersand |
| < | < | < | Less than |
| > | > | > | Greater than |
| " | " | " | Double quote |
| ' | ' | ' | Single quote / Apostrophe |
| (space) | |   | Non-breaking space |
| © | © | © | Copyright |
| ® | ® | ® | Registered |
| ™ | ™ | ™ | Trademark |
| – | – | – | En dash |
| — | — | — | Em dash |
| … | … | … | Ellipsis |
About This Tool
The HTML Entity Encoder and Decoder is a developer utility that converts special characters to their HTML entity equivalents and back. Whether you are preparing content for a web page, sanitizing user input, building email templates, or debugging encoded strings in API responses, this tool handles the conversion instantly in your browser with zero server-side processing.
What Are HTML Entities?
HTML entities are special notation sequences that represent characters in HTML documents. They begin with an ampersand (&) and end with a semicolon (;). Entities exist because certain characters have special meaning in HTML syntax: the less-than sign (<) opens a tag, the greater-than sign (>) closes one, the ampersand itself starts an entity reference, and quotation marks delimit attribute values. Without entities, using these characters in visible text content would confuse the browser's HTML parser. Entities come in two forms: named entities like & that use mnemonic keywords, and numeric entities like & that use the character's Unicode code point. Both are universally supported across all browsers and are functionally identical.
Why Encoding Matters for Web Security
HTML entity encoding is one of the primary defenses against Cross-Site Scripting (XSS) attacks. XSS is consistently ranked among the top web application vulnerabilities by the OWASP Foundation. When a website displays user-provided content without encoding it first, attackers can inject malicious HTML and JavaScript that executes in other users' browsers. Proper encoding converts potentially dangerous characters like < and > into their entity equivalents, rendering them as visible text rather than executable markup. While modern frameworks often handle encoding automatically, developers must understand the underlying mechanism to identify when automatic encoding might be bypassed and to manually encode content in edge cases such as inline scripts, URLs, or CSS contexts.
Named vs. Numeric Entities
Named entities are easier to read in source code. © is immediately recognizable as a copyright symbol, while © requires you to know the Unicode code point. However, named entities are limited to the set defined by the HTML specification, which covers common punctuation, mathematical symbols, Latin characters, and Greek letters, but does not include every Unicode character. Numeric entities can represent any of the 149,000+ characters in the Unicode standard, including emoji, CJK ideographs, and obscure technical symbols. Hexadecimal numeric entities (©) are also supported and are sometimes preferred because Unicode code charts list characters in hexadecimal. This tool lets you choose between named and numeric encoding depending on your requirements.
Encoding in Modern Development
In the era of UTF-8, which is now the default encoding for HTML5 documents, many characters can be included directly in your source code without entities. Accented characters, CJK characters, and even emoji render correctly when the document is served with the proper Content-Type header or meta charset tag. However, the five critical HTML syntax characters (&, <, >, ", ') must still be encoded when they appear in text content or attribute values. Additionally, non-breaking spaces ( ) remain necessary for layout control, and entities are useful for inserting characters that are difficult to type or visually ambiguous in source code, such as zero-width spaces, soft hyphens, and various dash types.
Common Use Cases
Developers use this tool when embedding code snippets in blog posts or documentation, where angle brackets and ampersands must be encoded to display correctly. Email developers encode special characters for maximum compatibility across diverse email clients. Content editors encode typographic characters like em dashes, curly quotes, and ellipses when working directly with HTML source. QA engineers decode entity-encoded strings from API responses or database records to verify the underlying content. Technical writers encode HTML examples within HTML documentation, creating the necessary layers of encoding. This tool handles all these scenarios with a simple paste-and-convert workflow, saving time and eliminating manual encoding errors.
Frequently Asked Questions
What are HTML entities and why do I need them?
What is the difference between named and numeric HTML entities?
How does HTML entity encoding prevent XSS attacks?
When should I encode HTML entities vs. use UTF-8 directly?
Can I use this tool to encode HTML for email templates?
Was this tool helpful?
You might also like
Pixel to Em/Rem Converter
Convert between px, em, rem, pt, and percentage units.
⏱ instantDev ToolsCSV to JSON Converter
Convert CSV data to JSON array of objects with header detection.
⏱ instantDev ToolsContext Window Calculator
Convert words, pages, or audio minutes to tokens. Check fit in every LLM window.
⏱ instant