🔤
HTML Entities Encoder
Encode or decode · named, decimal or hex entities · all 2,000+ named entities decoded
Ctrl+Enter = run
Output appears here

HTML Entities Encoder & Decoder

Free online HTML entities encoder and decoder. Escape <, >, &, " and ' — or every non-ASCII character too — as named, decimal or hex entities, and decode any named or numeric entity back to text. Essential for safely displaying user-generated content in HTML. Fully client-side.

Free No login 100% browser-based Your input never leaves your device

Try these next

What is a HTML Entities Encoder?

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 < (&lt;), > (&gt;), & (&amp;), " (&quot;), and ' (&#x27;). 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 &lt; instead. Entities start with & and end with ; and can be named (&amp;, &lt;, &gt;) or numeric (&#38;, &#60;, &#62;).
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 (&lt;, &amp;) 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.
Can this tool decode every named entity?
Yes. Decoding uses your browser's own HTML parser, which knows all 2,231 named character references in the HTML standard, from &amp; and &nbsp; to rare ones like &NotNestedGreaterGreater;. Decimal (&#169;) and hex (&#xA9;) entities are decoded too.
Which characters must always be HTML-encoded?
These five characters are the ones to escape: & → &amp; (always encode first), < → &lt;, > → &gt;, " → &quot; (in attributes), ' → &#x27; or &apos; (in attributes). Beyond these, any character can optionally be encoded by its Unicode code point: © → &copy; or &#169;. Modern UTF-8 HTML documents rarely need to encode non-ASCII characters.
What is the difference between named and numeric HTML entities?
Named entities use a readable name: &copy; (&amp;copy;), &nbsp; (non-breaking space), &euro; (€). Numeric entities use the Unicode code point in decimal (&#169;) or hexadecimal (&#xa9;). Numeric entities work for every Unicode character; named entities only exist for the characters listed in the HTML standard (2,231 names).
Does HTML encoding prevent XSS attacks?
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.
✓ Copied!