---
title: "HTML escape"
description: "Escape &, <, >, and quotes for safe HTML text. Converts the five core characters to entities."
---

> HTML: https://trendalyzer.app/tools/html-escape/
> Index: https://trendalyzer.app/llms.txt

# HTML escape

HTML escape replaces ampersands, angle brackets, and quotes with HTML entities so a string can sit in text or a quoted attribute without being parsed as markup. It escapes only five characters, is not a full-document sanitizer, and does not parse or rewrite tags.

Readiness: experimental

Input types: text

Output types: text

## Limits

- Escapes five characters only.

## Warnings

- This is not a sanitiser for full HTML documents.

## Example

Input: a<b

Output: a&lt;b

## Steps

1. **Paste the untrusted text** — Enter the string you intend to place in an HTML text node or quoted attribute.
2. **Run locally** — Ampersand is escaped first, then `<`, `>`, `"`, and `'`, so entities are not double-escaped.
3. **Embed the entities** — Copy the result into markup that treats the value as text, not as a full HTML document sanitizer.

## Five entities only

| Character | Entity |
| --- | --- |
| `&` | `&amp;` |
| `<` | `&lt;` |
| `>` | `&gt;` |
| `"` | `&quot;` |
| `'` | `&#39;` |

Ampersand must be first. This does **not** sanitize `javascript:` URLs or unquoted attributes.

## FAQ



### What characters are escaped by this tool?

The tool escapes the five core HTML/XML special characters: ampersand (& -> &amp;), less-than (< -> &lt;), greater-than (> -> &gt;), double quote (" -> &quot;), and single quote (' -> &#39;).

### Does HTML escaping protect against all XSS attacks?

HTML entity escaping protects text nodes and attribute values from tag injection. However, it does not sanitize dangerous URI schemes (like 'javascript:') or unquoted attribute contexts. Comprehensive defense requires context-aware sanitization.

### Why is the ampersand (&) escaped first?

Escaping the ampersand first ensures that subsequent entity replacements (such as &lt;) are not accidentally double-escaped into &amp;lt;.

### Is single quote represented as &apos; or &#39;?

The tool uses numeric entity '&#39;' for maximum backward compatibility across older browsers and XML/HTML parser implementations.
