All tools

HTML encoder

Escape or decode HTML entities.

HTML encoder
Action
InputTEXT

Press Command or Control plus Enter to run. Tab inserts indentation; press Escape, then Tab, to leave the editor.

Result
Your result will appear here.
Ready1 line · 20 chars

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 &lt; and & becomes &amp;.

This tool escapes the five key characters, & < > " ', and decodes named and numeric entities such as &copy; or &#169; back to plain text.

How to use the HTML encoder

  1. Choose Encode or Decode in the Action menu.
  2. Paste your HTML or text into the Input editor.
  3. Click Escape HTML or Decode HTML, or press Ctrl + Enter (Cmd + Enter on Mac).
  4. 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

&lt;a href=&quot;/search?q=tom&amp;jerry&quot;&gt;Tom&#39;s page&lt;/a&gt;

Common errors and how to fix them

&amp;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 &lt; and &#60;?

Both represent <. &lt; is a named entity and &#60; 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 &amp; for HTML documents, while URL encoding uses codes like %26 for URLs. Use the URL encoder for links and query strings.