Skip to main content

HTML Encode: Escape Special Characters for Safe Display

9 min read

Special characters in text (e.g. <, >, &, quotes) can break HTML or be interpreted as markup. Encoding them as HTML entities (e.g. < > &) ensures they display as literal characters and do not break the page or introduce security issues. This guide explains when to encode and how to do it in your browser.

What HTML Encoding Does

Characters that have meaning in HTML are replaced by entity references or numeric codes. For example, < becomes &lt; and & becomes &amp;. That prevents the browser from interpreting the content as tags or entities. Use encoding when inserting user-generated or external text into HTML.

When to Encode

  • User input and display: Any text that will be shown in HTML and might contain <, >, &, or quotes.
  • Preventing XSS: Encoding output helps prevent script injection when the result is placed in HTML.
  • Attributes and quoted strings: Encode characters that would break attribute values.

Use Our Tool

Our HTML Encode converts your text to entity form. Paste and copy. Runs in your browser. No sign-up. Use it to make text safe for inclusion in HTML.

Related tools