Skip to main content

HTML Escape - Convert Characters to Entities

Convert HTML-significant characters such as &, <, >, and quotes to entities for display as text. Safe output still depends on the exact HTML context.

Runs in browser - Tool input is not submitted html escape xss security
< → &lt;
> → &gt;
& → &amp;
" → &quot;

How to escape HTML special characters

Paste markup or plain text to replace ampersands, angle brackets, and quotation marks with HTML entities. The escaped result can be displayed as literal code without the browser treating tags such as <script> or <strong> as page structure.

This tool performs text-to-entity conversion; it does not validate a complete application security policy. Safe output handling is context-sensitive, so use your framework's established encoder or sanitizer when rendering untrusted data in production. To recover readable characters from entities, use the HTML unescape tool. For a query parameter or URL component, use the URL encoder because HTML entities and percent encoding solve different problems.

Display markup literally

Replace angle brackets and ampersands so a browser shows a code sample instead of interpreting it as elements.

Protect the HTML text context

Entity encoding prevents plain text from opening a tag, although attributes and scripts need context-specific handling.

Encode at the output boundary

Keep the stored value unchanged and escape it for the exact destination where the application renders it.

HTML characters to escape in text and attributes

These references preserve the literal character while preventing it from being read as nearby HTML syntax.

Character Escaped output Why it matters
& &amp; Starts every named or numeric character reference
< &lt; Can open a tag when left literal in an HTML text value
> &gt; Can close tag syntax and is commonly escaped with the opening bracket
" &quot; Can close an attribute enclosed in double quotes
' &#39; Can close an attribute enclosed in single quotes

Related developer tools

Percent-encode special characters for safe inclusion in URLs
Encode binary or text data to Base64 for transport
Write and preview Markdown that renders HTML safely
Build regex patterns to detect unescaped HTML in text

Understand the trust boundary before relying on output

These maintained explanations cover the behavior, limits, and decisions that the interactive result alone cannot show.