HTML Entity Encoder & Decoder
HTML Entity Encoder & Decoder
Encode or decode HTML entities.
Runs entirely in your browser
How to use this tool
- Fill in the inputs.
- Read the result.
- Copy or download as needed.
About the HTML Entity Encoder & Decoder
The HTML Entity Encoder & Decoder converts special characters like `<`, `>`, `&`, `"`, and `'` into their corresponding HTML entities (such as `<`, `>`, and `&`), or reverses the process to turn entities back into their original readable characters. This is essential whenever text needs to be safely displayed inside an HTML page without being misinterpreted as markup.
Failing to encode these characters correctly is a common source of both visual bugs (where a `<` in your text accidentally starts what looks like a broken tag) and security issues (where unencoded user input can lead to cross-site scripting vulnerabilities), so having a fast, reliable way to encode and decode is a genuinely useful safety habit for anyone working with HTML.
Encoding scans your input text and replaces each of the five characters with special meaning in HTML — ampersand, less-than, greater-than, double quote, and single quote — with its corresponding named entity, leaving every other character completely untouched. This covers the core set of characters that must always be encoded to safely display arbitrary text within HTML content or attributes.
Decoding takes the opposite approach: it assigns your input text as the `innerHTML` of a hidden, temporary text area element, which causes the browser's own built-in HTML parser to interpret any entities and convert them back to their original characters, and then reads the resulting plain text back out. This method correctly handles not just the basic five entities but also any other valid HTML entity your browser recognizes, such as ` ` or numeric character references.
Common use cases
- Safely encoding user-generated or external text before displaying it inside an HTML page.
- Decoding HTML entities found in scraped or copied web content to see the original readable text.
- Preparing text containing angle brackets or ampersands to be safely shown as literal text inside HTML, rather than being interpreted as markup.
- Cleaning up text copied from a web page that displays entity codes instead of the intended symbols.
- Learning or teaching which characters require HTML encoding and what their corresponding entities look like.
Tips and best practices
- Always encode text before inserting it into HTML if it comes from an untrusted or user-supplied source, since unencoded special characters can break page layout or introduce security vulnerabilities.
- The five characters handled by encoding here — `&`, `<`, `>`, `"`, and `'` — cover the essential cases for safely displaying arbitrary text as HTML content.
- Decoding uses your browser's own HTML parser, so it correctly handles a wide range of named and numeric entities beyond just the basic five.
- If you are encoding text for use inside an HTML attribute specifically (like a `title` or `alt` attribute), make sure quotation marks are encoded, since this tool handles both single and double quotes.