HTML Entity Encoder/Decoder
Encode and decode HTML entities
Input
Output
How to use the HTML Entity Encoder/Decoder
- •Paste or type your text into the input area. For encoding, enter raw text that contains special characters. For decoding, enter text that contains HTML entities like
&or<. - •Select the mode: "Encode" converts characters to their HTML entity equivalents, "Decode" converts HTML entities back to their original characters.
- •Review the output displayed in the result area. Encoded output replaces special characters with named or numeric entities. Decoded output shows the original characters.
- •Copy the result for use in your HTML documents, templates, or content management system.
What are HTML Entities?
HTML entities are special sequences of characters used to represent characters that have special meaning in HTML or that cannot be easily typed on a keyboard. They begin with an ampersand (&) and end with a semicolon (;).
There are two forms:
- •Named entities: Use a human-readable name, like
&for&,<for<,>for>,"for", and'for'. - •Numeric entities: Use the Unicode code point, either in decimal (
<for<) or hexadecimal (<for<).
The five characters that must always be encoded in HTML content are:
| Character | Entity | Why |
|-----------|--------|-----|
| < | < | Starts an HTML tag |
| > | > | Ends an HTML tag |
| & | & | Starts an entity |
| " | " | Delimits attribute values |
| ' | ' | Delimits attribute values |
If you include a literal < in your HTML, the browser interprets it as the beginning of a tag, which can break your page layout or, worse, create a Cross-Site Scripting (XSS) vulnerability. Encoding these characters ensures that the browser displays them as text rather than interpreting them as markup.
Beyond the critical five, HTML entities also represent characters not found on standard keyboards: © for the copyright symbol, € for the euro sign, — for an em dash, and for a non-breaking space. The full HTML entity list includes hundreds of named entities covering mathematical symbols, arrows, Greek letters, and more.
Common use cases
- •Preventing XSS attacks: Encoding user-generated content before rendering it in HTML is a fundamental security practice. Any text displayed on a web page that originated from user input must be entity-encoded.
- •Displaying code in HTML: When showing HTML, XML, or JavaScript code snippets on a web page, angle brackets and ampersands must be encoded so the browser does not interpret them as actual markup.
- •Email template development: HTML email clients have varying support for character sets. Using HTML entities ensures special characters render correctly across all email clients.
- •CMS content migration: When moving content between content management systems, HTML entities may need to be decoded and re-encoded to match the target system's requirements.
FAQ
Q: Should I encode all characters or just the special ones?
A: Only the five reserved characters (<, >, &, ", ') need encoding for correctness. Non-ASCII characters (accented letters, emoji) can be encoded as numeric entities but are better handled by declaring charset="UTF-8" in your HTML and using the literal characters.
Q: What is the difference between named and numeric entities?
A: They produce the same result. < and < both render as <. Named entities are more readable but not every character has a named entity. Numeric entities work for any Unicode code point.
Q: Does encoding affect SEO?
A: No. Search engines decode HTML entities during indexing, so & in your source is treated the same as & in your displayed text. Use entities for correctness, not for SEO purposes.
Is my data safe?
Yes. This tool runs entirely in your browser. Your data is never sent to our servers.
How to use the HTML Entity Encoder/Decoder
- Paste or type your text into the input area. For encoding, enter raw text that contains special characters. For decoding, enter text that contains HTML entities like
&or<. - Select the mode: "Encode" converts characters to their HTML entity equivalents, "Decode" converts HTML entities back to their original characters.
- Review the output displayed in the result area. Encoded output replaces special characters with named or numeric entities. Decoded output shows the original characters.
- Copy the result for use in your HTML documents, templates, or content management system.
What are HTML Entities?
HTML entities are special sequences of characters used to represent characters that have special meaning in HTML or that cannot be easily typed on a keyboard. They begin with an ampersand (&) and end with a semicolon (;).
There are two forms:
- Named entities: Use a human-readable name, like
&for&,<for<,>for>,"for", and'for'. - Numeric entities: Use the Unicode code point, either in decimal (
<for<) or hexadecimal (<for<).
The five characters that must always be encoded in HTML content are:
| Character | Entity | Why |
|-----------|--------|-----|
| < | < | Starts an HTML tag |
| > | > | Ends an HTML tag |
| & | & | Starts an entity |
| " | " | Delimits attribute values |
| ' | ' | Delimits attribute values |
If you include a literal < in your HTML, the browser interprets it as the beginning of a tag, which can break your page layout or, worse, create a Cross-Site Scripting (XSS) vulnerability. Encoding these characters ensures that the browser displays them as text rather than interpreting them as markup.
Beyond the critical five, HTML entities also represent characters not found on standard keyboards: © for the copyright symbol, € for the euro sign, — for an em dash, and for a non-breaking space. The full HTML entity list includes hundreds of named entities covering mathematical symbols, arrows, Greek letters, and more.
Common use cases
- Preventing XSS attacks: Encoding user-generated content before rendering it in HTML is a fundamental security practice. Any text displayed on a web page that originated from user input must be entity-encoded.
- Displaying code in HTML: When showing HTML, XML, or JavaScript code snippets on a web page, angle brackets and ampersands must be encoded so the browser does not interpret them as actual markup.
- Email template development: HTML email clients have varying support for character sets. Using HTML entities ensures special characters render correctly across all email clients.
- CMS content migration: When moving content between content management systems, HTML entities may need to be decoded and re-encoded to match the target system's requirements.
FAQ
Q: Should I encode all characters or just the special ones?
A: Only the five reserved characters (<, >, &, ", ') need encoding for correctness. Non-ASCII characters (accented letters, emoji) can be encoded as numeric entities but are better handled by declaring charset="UTF-8" in your HTML and using the literal characters.
Q: What is the difference between named and numeric entities?
A: They produce the same result. < and < both render as <. Named entities are more readable but not every character has a named entity. Numeric entities work for any Unicode code point.
Q: Does encoding affect SEO?
A: No. Search engines decode HTML entities during indexing, so & in your source is treated the same as & in your displayed text. Use entities for correctness, not for SEO purposes.
Is my data safe?
Yes. This tool runs entirely in your browser. Your data is never sent to our servers.