HTML Entity Encode

Escape text into HTML entities

Convert characters such as <, >, & and quotes into HTML entities so text displays literally in a web page - optionally encoding accented letters, symbols and emoji too.
Try an example:

Output will appear here...

About HTML Entity Encode

How it works

  1. The text is scanned character by character.
  2. HTML special characters are always replaced: & → &amp;, < → &lt;, > → &gt;, " → &quot;, ' → &#x27;.
  3. Depending on the mode, accented letters, symbols and emoji are also replaced - by a named entity where one exists (© → &copy;) or by their Unicode number (&#xA9;).

What you need

  • Any text or HTML code you want to show as plain text on a page.

Tips

  • To show code samples on a web page, encode them first - otherwise the browser treats them as real HTML.
  • Escaping user input before inserting it into HTML is a basic defence against cross-site scripting (XSS).
  • Modern pages served as UTF-8 do not need non-ASCII characters encoded - use "Only HTML special characters" unless an old system requires it.

Runs in your browser. Everything happens in your browser - the text you enter is never uploaded.

Frequently asked questions

What are HTML entities?+

Codes that represent characters in HTML: named ones like &amp;copy; or numeric ones like &amp;#169;. Browsers display them as the character instead of interpreting it as code.

Does encoding stop XSS attacks?+

Escaping < > & " ' when inserting text into HTML content is an essential part of preventing XSS, but attributes, URLs and JavaScript contexts need their own escaping rules.