HTML Encode

Convert HTML special characters into safe entities so code displays as text instead of rendering.

Loading tool…

How to use the HTML Encode

When you want to show HTML code on a web page, characters like <, > and & must be converted to entities (&lt;, &gt;, &amp;) so the browser displays them instead of running them. This also helps prevent cross-site scripting when outputting user input.

  1. 1Paste the text or HTML you want to encode.
  2. 2Click "Encode" to convert special characters to entities.
  3. 3Copy the safe, escaped output.
  4. 4Paste it into your page to display code as text.

Frequently asked questions

Which characters are encoded?

The five core characters &, <, >, " and ' are converted to their named or numeric HTML entities.

Does this prevent XSS?

Encoding output is an important part of preventing cross-site scripting, though a full defense also validates input.