Developer Tool

HTML Encoder / Decoder

Encode special characters to safe HTML entities, or decode HTML entities back to readable text — instantly in your browser.

HTML Encoder / Decoder
Encode special characters to HTML entities and decode them back
Input
Output
Output appears here...

Disclaimer. This tool is provided for informational purposes only. Always verify that user-supplied content is properly escaped before deploying to production. Read full disclaimer →

About HTML Encoder and Decoder

HTML encoding converts special characters to their HTML entity equivalents to prevent browser misinterpretation. Critical characters: less-than sign becomes <, greater-than sign becomes >, ampersand becomes &, double quote becomes ", and single quote becomes ' or '. This prevents content from being interpreted as HTML tags.

Why it matters: Cross-Site Scripting (XSS) attacks inject malicious scripts via unencoded user input that the browser executes as HTML. Always HTML-encode user-supplied content before inserting it into HTML pages. Modern frameworks like React and Angular do this automatically, but raw string concatenation in older code or email templates is vulnerable. Use this tool to safely embed code examples in web pages, encode email template content, or verify that your application is properly escaping user input before display.

Worked Example

Paste this snippet into the input box and press Encode:

<a href="page?a=1&b=2">Tom & Jerry's</a>

The output becomes &lt;a href=&quot;page?a=1&amp;b=2&quot;&gt;Tom &amp; Jerry&#39;s&lt;/a&gt;. Every angle bracket, quote and ampersand has been replaced, so a browser will display the snippet as visible text instead of building a link. Pressing Decode on that output restores the original exactly.

Common Mistakes

Where You Would Use This

Tips for Reliable Results

Work in one direction at a time and keep the original text safe. Encode once, paste the result into your page, and test it in a browser to confirm the characters show as you expect. If something looks double-escaped, such as visible &amp; on the page, decode one step and look again before changing anything. The “Characters replaced” figure beneath the output is an approximate measure of how much changed, which is a quick way to confirm that something happened on a long block. If it shows 0 after you press Encode, the text contained none of the five special characters, so there was nothing to escape. Compare the result with a small test string first, such as a single ampersand, so you know what to expect before you run a full template through the tool. For code samples, remember that indentation and line breaks pass through unchanged, so wrap the result in a preformatted block if layout matters.

Frequently Asked Questions

The encoder converts the five characters that have special meaning in HTML: < becomes &lt;, > becomes &gt;, & becomes &amp;, " becomes &quot;, and ' becomes &#39;.
Unencoded user input inserted directly into an HTML page can be interpreted as executable markup or scripts, enabling Cross-Site Scripting (XSS) attacks. Encoding special characters ensures user-supplied content is always displayed as plain text, not executed as code.
Yes, in addition to the five named entities, the decoder also converts numeric character references (e.g. &#39;) back to their corresponding characters.
Yes, React, Angular, and Vue automatically escape values rendered through their templating systems. This tool is most useful for raw string concatenation, email templates, static HTML generation, or manually verifying that escaping is working correctly.