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.
<
→
<
>
→
>
&
→
&
"
→
"
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 |
|---|---|---|
| & | & | Starts every named or numeric character reference |
| < | < | Can open a tag when left literal in an HTML text value |
| > | > | Can close tag syntax and is commonly escaped with the opening bracket |
| " | " | Can close an attribute enclosed in double quotes |
| ' | ' | Can close an attribute enclosed in single quotes |
Related developer tools
Understand the trust boundary before relying on output
These maintained explanations cover the behavior, limits, and decisions that the interactive result alone cannot show.