About the HTML encoder
HTML encoding replaces characters that have special meaning in HTML with entities, so they are shown as text instead of being treated as markup. For example, < becomes < and & becomes &.
This tool escapes the five key characters, & < > " ', and decodes named and numeric entities such as © or © back to plain text.
How to use the HTML encoder
- Choose Encode or Decode in the Action menu.
- Paste your HTML or text into the Input editor.
- Click Escape HTML or Decode HTML, or press Ctrl + Enter (Cmd + Enter on Mac).
- Click Copy result to copy the output.
Example
Escape a code snippet so it shows as text
Input
<a href="/search?q=tom&jerry">Tom's page</a>Output
<a href="/search?q=tom&jerry">Tom's page</a>Common errors and how to fix them
&amp; shows on the page
The text was escaped twice. Escape untrusted text once, right before inserting it into HTML. React already escapes text in JSX, so don't escape it yourself there.
HTML tags show up as text instead of rendering
The markup was escaped when it should have been inserted as HTML. Only escape text that should be displayed literally; trusted HTML needs to be inserted without escaping.
Escaping didn't stop an XSS in an attribute
Escaping protects text and quoted attribute values, but not href="javascript:..." or unquoted attributes. Always quote attributes and check that URLs start with http: or https:.
Good to know
- Encoding is useful for showing code snippets on a web page or putting user-provided text into HTML.
- Only the five special characters are escaped; other characters, including emoji, are left as they are.
- Escaping helps, but correct protection against cross-site scripting depends on context. In real applications, use your framework's built-in escaping.
Frequently asked questions
What is the difference between < and <?
Both represent <. < is a named entity and < is a numeric entity using the character's code. Browsers treat them the same, and this tool decodes both.
Do I need to escape quotes?
Quotes matter inside HTML attribute values, where an unescaped quote can end the attribute early. Escaping them everywhere is the safe default.
Is HTML encoding the same as URL encoding?
No. HTML encoding uses entities like & for HTML documents, while URL encoding uses codes like %26 for URLs. Use the URL encoder for links and query strings.