Free online HTML entities encoder and decoder. Convert special characters like <, >, &, ", ' to their HTML entity equivalents (<, >, &, ", ') and back. Essential for safely displaying user-generated content in HTML. Fully client-side.
FreeNo login100% browser-basedNo data sent to servers
HTML entities are escape sequences for characters that have special meaning in HTML or that cannot be reliably typed. The five characters that must always be escaped in HTML content are < (<), > (>), & (&), " ("), and ' ('). Failing to escape these can cause HTML injection or XSS vulnerabilities.
This tool encodes any text to its HTML entity representation (replacing special characters with their &entity; or &#code; forms) and decodes HTML entities back to plain text. Useful for safely embedding user-generated content in HTML, writing documentation, and debugging HTML parsing issues.
What are HTML entities?
HTML entities are special codes used to display reserved characters in HTML. For example, < and > are used to define HTML tags, so to display a literal < character you must write < instead. Entities start with & and end with ; and can be named (&, <, >) or numeric (&, <, >).
When do I need to encode HTML entities?
You need HTML entity encoding when: displaying user-generated content in HTML (to prevent XSS attacks), putting literal angle brackets or ampersands in HTML text, embedding code examples in web pages, and working with CMS systems that process HTML. Any time user input is rendered as HTML, it must be entity-encoded first.
What's the difference between HTML encoding and URL encoding?
HTML encoding converts characters to HTML entities (<, &) for safe rendering in HTML. URL encoding converts characters to percent-encoded sequences (%3C, %26) for safe use in URLs. Both escape the same dangerous characters but in different formats for different contexts. Use HTML encoding for HTML content, URL encoding for query parameters and URLs.
What is the difference between HTML entities and URL encoding?
HTML entities encode characters for safe display inside HTML documents (e.g. & → & to prevent it being parsed as an entity). URL encoding (percent-encoding) encodes characters for safe inclusion in URLs (e.g. & → %26). Use HTML entities in HTML content; use URL encoding in URLs and query parameters. Never mix them up.
Yes — proper HTML encoding is the primary defence against Cross-Site Scripting (XSS). By encoding user-supplied input before inserting it into HTML, you prevent browsers from interpreting injected scripts. Always encode on output (not input) and encode in the correct context: HTML encoding for HTML content, JavaScript encoding for JS strings, CSS encoding for CSS values. Never use a single encoding for all contexts.