HTML Encode
Escape text so it shows exactly as written inside a web page instead of being read as HTML. Angle brackets, ampersands and quotes become entities like < and &, which is what you need to show code samples, user comments or special characters safely.
How to HTML Encode Text
Quick answer: paste your text or code; the escaped version appears below, ready to paste into a web page.
-
1
Paste your text
Code, comments or symbols.
-
2
Choose options
Quotes and non-ASCII characters.
-
3
Check the result
Special characters become entities.
-
4
Copy it
Paste it into your page.
What You Get
What Is HTML Encoding?
Web browsers read < and > as the start and end of HTML tags and & as the start of a special code. To show these characters as text, they must be written as entities: < for <, > for > and & for &. Quotes are written as " and ' when the text goes inside an attribute. HTML encoding, also called escaping, replaces all of them in one go.
Why It Matters
Without escaping, a code sample like <p> disappears from your page because the browser treats it as a real paragraph tag. Worse, text typed by users could change your page or run scripts if it is inserted without escaping. Encoding turns any text into something that is always shown exactly as written, which is why it is the basis of safe web development.
Options Explained
Encode quotes is needed when the text goes inside an HTML attribute, such as title="…". It can be turned off for text placed between tags, where quotes are harmless. Encode every non-ASCII character turns letters like é, dashes, symbols and emoji into numeric entities like é. The result contains only basic ASCII characters, which is useful for old systems, some email templates and files saved in old encodings.
Example
Encoding <p class="note">Tom & Jerry</p> gives <p class="note">Tom & Jerry</p>. Pasted into a page, it shows the original code as visible text. To turn entities back into characters, use HTML Decode.
Who Uses HTML Encoding?
Bloggers and teachers showing code examples, developers inserting text into templates by hand, people writing documentation and help articles, email template designers, and content editors whose system shows raw tags instead of text. It is also handy for preparing text for XML files, which use the same five special characters.
Good to Know
Encode text only once: encoding & again gives &amp;, which shows as "&" on the page. Modern pages saved as UTF-8 do not need accented letters encoded, so leave that option off unless you have a reason. Line breaks and spaces are kept as they are; use <br> tags or the TXT to HTML converter if you need the line breaks to show on the page.
Step by Step
Paste the code or text exactly as it should appear on the page. Keep Encode quotes ticked if the text will go inside an attribute, and tick the non-ASCII option only if the destination cannot handle UTF-8. Copy the encoded text into your page, post or template, then preview it: the special characters should show as normal characters, not disappear or turn into formatting.
For code samples, place the encoded text inside pre and code tags so that spacing and line breaks are kept on the page.
Private, Free and Instant
The encoder is free and handles long documents up to 5 MB. There is no sign-up, no limit and nothing to install. Everything runs inside your browser, so passwords, tokens, customer data and private messages are never uploaded, logged or stored anywhere. The result updates instantly as you type or paste, and you can open a text file from your device and download the result as a new file. It works on Windows, Mac, Linux, Chromebooks, iPhone and Android.
Encoding HTML Safely: Which Characters Need Escaping
HTML gives a few characters special meaning: less-than and greater-than begin and end tags, the ampersand starts an entity, and quotation marks end attributes. To show these characters as text on a page, they must be written as entities.
The key entities
- & becomes &
- < becomes < and > becomes >
- Double quote becomes "
- Apostrophe becomes '
Why it matters
Encoding user-supplied text before showing it is a basic defence against cross-site scripting, where injected script runs in other people's browsers. It also lets you display code samples on a web page. Remember that encoding depends on context; text inside a script or a URL needs different handling than text between tags. To reverse it, use HTML decode.
Frequently Asked Questions
Questions about HTML encoding