HTML Encoder / Decoder
Encode special characters to safe HTML entities, or decode HTML entities back to readable text — instantly in your browser.
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 <a href="page?a=1&b=2">Tom & Jerry's</a>. 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
- Encoding twice. Running the output through Encode again turns
<into&lt;, and the page then shows the literal text “<” to readers. - Expecting every named entity to decode. This tool decodes
&,<,>,",','and decimal numbers such as₹(which gives ₹). Names like©and hexadecimal forms like₹are left untouched. - Treating encoding as a complete security fix. Encoding suits text placed between tags. Values placed inside JavaScript, URLs or CSS need different escaping.
- Decoding text you do not trust and then inserting it as HTML. Decoding turns harmless entities back into live tags.
Where You Would Use This
- Showing a code sample inside a blog post or documentation page without the browser running it.
- Preparing text for an email template where raw ampersands or quotes break the layout.
- Reading a scraped or exported string full of
&and"to see what it originally said. - Checking by eye whether your application escaped a user’s input the way you expected.
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 & 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
< becomes <, > becomes >, & becomes &, " becomes ", and ' becomes '.') back to their corresponding characters.