HTML Entity Encoder: Encode and Decode HTML Entities
HTML entities are special codes that represent reserved or special characters in HTML. Without them, characters like <, >, and & would break your HTML structure or expose your site to XSS attacks.
The 5 Most Important HTML Entities
&The & symbol starts all HTML entities, so it must always be encoded
<Less-than opens HTML tags — must be encoded in text content
>Greater-than closes HTML tags — encode for safety
"Double quote is used in attribute values — encode inside attr="..."
'Single quote is used in attribute values — encode inside attr='...'
When to Encode HTML Entities
- • In template engines: When outputting user-provided data into HTML (prevents XSS)
- • In email templates: HTML email clients are strict — always encode special characters
- • In attribute values: Any quotes inside attributes need encoding
- • Displaying code: Use < and > to show <html> tags visually
- • Special symbols: Use ©, ™, € for © ™ € in HTML
When NOT to Encode
Don't encode characters that are inside <script> or <style>tags — those contexts have their own escaping rules. Also don't double-encode already-encoded entities (turning & into &amp;).
Encode or decode HTML entities now
Instant conversion · Reference table included · 100% free
Open HTML Entity Encoder →Frequently Asked Questions
What are HTML entities?
HTML entities are special codes used to display reserved or special characters in HTML. For example, & displays & (ampersand), < displays < (less-than), and > displays > (greater-than). Without entities, these characters would be interpreted as HTML markup.
Why do I need to encode HTML entities?
You need to encode HTML entities to: (1) display characters that have special meaning in HTML like <, >, and &; (2) prevent XSS (cross-site scripting) attacks when displaying user-provided text; (3) display special symbols like © (©) and ™ (™) correctly across all browsers.
What is the HTML entity for &?
The HTML entity for the ampersand (&) is &. Always encode & as & in HTML text content and attribute values, since & starts all other HTML entities and can confuse parsers if left unencoded.
What is the HTML entity for a space?
A regular space is already valid in HTML. The HTML entity is a non-breaking space — it prevents line breaks between words and ensures the space is always visible (even multiple spaces). Use when you need a space that cannot be broken across lines.
How do I decode HTML entities?
Switch the tool to Decode mode, paste your HTML-encoded text (containing <, &, etc.) and click convert. The tool uses the browser's built-in HTML parser to accurately decode all standard entities back to their original characters.