Text to escape

Escaped text

Why escape text in HTML?

Escaping HTML is necessary when you want to display text that contains special characters that have meaning in HTML syntax. For example, if you want to display the character "<" in HTML, you need to escape it as "&lt;" to prevent it from being interpreted as the start of an HTML tag.

Examples of HTML escaping

Original text

<div class="container">
  <h1>Hello "World"</h1>
  <p>This is a paragraph with <strong>bold</strong> text.</p>
  <p>Special characters: & < > ' "</p>
  <a href="https://example.com?param=value&another=value">Link</a>
</div>

Escaped text

&lt;div class=&quot;container&quot;&gt;
  &lt;h1&gt;Hello &quot;World&quot;&lt;/h1&gt;
  &lt;p&gt;This is a paragraph with &lt;strong&gt;bold&lt;/strong&gt; text.&lt;/p&gt;
  &lt;p&gt;Special characters: &amp; &lt; &gt; &#39; &quot;&lt;/p&gt;
  &lt;a href=&quot;https://example.com?param=value&amp;another=value&quot;&gt;Link&lt;/a&gt;
&lt;/div&gt;

Common HTML entities

CharacterEntityDescription
&&amp;Ampersand
<&lt;Less than
>&gt;Greater than
"&quot;Double quote
'&#39;Single quote

When to use HTML escaping

  • When displaying user-generated content to prevent XSS (Cross-Site Scripting) attacks
  • When you need to display HTML code as text rather than having it rendered as HTML
  • When working with data that might contain special characters in HTML templates
  • When generating HTML dynamically from untrusted sources
  • When displaying code examples that contain HTML tags

This tool is useful for preparing text to be safely included in HTML documents, ensuring that special characters are properly escaped to prevent rendering issues or security vulnerabilities.

Security Tip:

Always escape user-generated content before displaying it in HTML to prevent Cross-Site Scripting (XSS) attacks. This is especially important for content that might contain HTML tags or JavaScript code.

Related Tools

All Tools

See all available tools