Transmission Zero

HTML Encoder


When copying and pasting text into (X)HTML source code, it’s important to remember to escape characters such as ‘<’, ‘>’, and ‘&’. Failure to do so can cause undesired behaviour in your web page, varying from text such as “#include <iostream>” being displayed as “#include”, to entire sections of your web page mysteriously eating themselves up. Worse still, not all browsers deal with this issue in the same way, so whilst your web page might look fine in one browser, it could have serious issues in another browser.

The tool on this page is intended to handle the task of escaping special characters for you, replacing characters such as ‘<’ with the string “&lt;”. The most common application for this is when you want to display code on your web page, for example HTML and C code both typically make heavy use of the characters ‘<’, ‘>’, and ‘&’—if just one of these is not displayed properly on a web page, the code probably won’t work. But actually, any text you want to copy and paste into (X)HTML source code should be sanitised in this way, to ensure it is displayed correctly.

Encode Your Text

To use the tool, place your text in the “input text” box, press the “encode” button, and the encoded text will appear in the “output text” box. If your browser allows copying to the clipboard, you can use the “copy to clipboard” button to copy the encoded HTML. You can choose whether to enclose the output in a “<pre><code>” block (useful for source code where you need to preserve spacing), and you can choose whether to encode quotation marks (not needed unless the text is being placed inside an (X)HTML attribute).

If you are using Windows 7 with Internet Explorer 9, you can quickly access this tool by dragging the current browser tab and dropping it onto the taskbar.


Input Text

Output Text

Any text you encode using this tool is encoded by your web browser, and is not sent to any web servers or stored anywhere without your knowledge.