Displaying user input as text
Comments, names and search terms must be escaped before insertion, or a submitted script tag executes for every subsequent viewer.
Escapes or unescapes HTML special characters so text renders safely.
—Escapes or unescapes HTML special characters so text renders safely.
<b>Bold</b> & "quotes"
<b>Bold</b> & "quotes"
Escaped text displays literally instead of being parsed.
Escaped text is inert HTML; unescaped text renders as markup.
Your input is processed entirely in your browser and never sent to a YAS server.
curl -X POST "https://yas.sh/api/v1/tools/html-escape" \
-H "Content-Type: application/json" \
-d '{"input":"<b>hi</b>","mode":"encode"}'const res = await fetch("https://yas.sh/api/v1/tools/html-escape", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"input": "<b>hi</b>",
"mode": "encode"
}),
});
const data = await res.json();import requests
r = requests.post("https://yas.sh/api/v1/tools/html-escape", json={"input":"<b>hi</b>","mode":"encode"})
data = r.json()| Field | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | HTML or plain text |
| mode | "encode" | "decode" | No (default "encode") | Direction |
{ "slug": "html-escape", "result": "<b>hi</b>", "mode": "encode" }Escape or unescape HTML entities (& < > " ').
400 VALIDATION_ERROR — invalid input or unsupported option.413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).Escaping replaces characters that carry meaning in HTML with entity references: & becomes &, < becomes <, > becomes >, " becomes " and ' becomes '. The ampersand must be escaped first, otherwise escaping the others would double-encode the ampersands they introduce. Unescaping reverses the mapping and additionally resolves named and numeric character references.
Escaping is context-dependent, which is the part that causes vulnerabilities. HTML-escaping is correct for text content and quoted attribute values, but it is not sufficient inside a script block, inside a style block, in an unquoted attribute, or in a URL attribute such as href — where a javascript: scheme survives escaping untouched. Each context needs its own encoding, and applying the wrong one produces markup that looks escaped and is still exploitable.
Comments, names and search terms must be escaped before insertion, or a submitted script tag executes for every subsequent viewer.
Documentation that displays HTML must escape it, otherwise the browser renders the example instead of showing it.
Email templates concatenate strings more often than web templates do, which makes explicit escaping essential.
When a page displays an entity as literal visible text rather than as the character it stands for, an extra encoding pass was applied somewhere in the pipeline. Unescaping once shows you what the value was before that pass.
What this tool deliberately does not do, and where it will disagree with other implementations.