What are HTML entities?
HTML entities are special sequences of characters used to represent characters that have special meaning in HTML, or characters that are difficult to type. They start with an ampersand & and end with a semicolon ;. For example, < represents the less-than sign <, and & represents the ampersand itself. Without entities, a browser might misinterpret these characters as HTML tags or attribute delimiters.
When to use HTML encoding
You should encode user-supplied content before inserting it into HTML to prevent cross-site scripting (XSS) attacks. If a user types <script>alert('xss')</script> and you display it without encoding, the browser will execute the script. Encoding converts the angle brackets to < and >, making the input display as literal text rather than executable code. Encoding is also needed when embedding content inside HTML attributes.
Common HTML entities
The most frequently used entities are: & (ampersand &), < (less-than <), > (greater-than >), " (double quote "), ' (single quote '), (non-breaking space), © (copyright ©), ® (registered trademark ®), and — (em dash —).
How this tool works
The encoder replaces the five characters with special HTML meaning (&, <, >, ", ') with their corresponding entity codes. The decoder uses the browser's own HTML parser — a temporary <textarea> element — to safely convert any entity sequence back to its character, supporting both named entities like © and numeric entities like ©. All processing happens locally in your browser.