HTML entity encoder and decoder
Escape text as HTML entities, named or numeric, or decode entities back to characters.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/html-entities \
-H 'Content-Type: application/json' \
-d '{"input":{"text":"<p>Café & \"tea\"</p>"}}'
import json, urllib.request
body = {'input': {'text': '<p>Café & "tea"</p>'}}
request = urllib.request.Request("https://setget.net/v1/tools/html-entities", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/html-entities", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"text":"<p>Café & \"tea\"</p>"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "html-entities",
"input": {
"text": "<p>Café & \"tea\"</p>"
}
}
{
"input": {
"text": "<p>Café & \"tea\"</p>"
}
}
Endpoint: POST /v1/tools/html-entities. Over MCP: run_tool with slug: "html-entities".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
text |
string | yes | The text to escape, or text with entities to decode. |
action |
string | no | Encode characters as entities, or decode entities to characters. One of: encode, decode. Default: "encode". |
style |
string | no | How to write entities: named where a name exists (é), decimal (é) or hex (é). One of: named, decimal, hex. Default: "named". |
scope |
string | no | What to encode: "special" is only & < > " and ', "non-ascii" is only characters outside plain ASCII, "all" is both. One of: all, special, non-ascii. Default: "all". |
Examples
Input
{
"text": "<p>Café & \"tea\"</p>"
}Result
{
"text": "<p>Café & "tea"</p>",
"replaced": 8
}Only non-ASCII characters, leaving the markup alone
Input
{
"text": "Café <b>€5</b>",
"style": "decimal",
"scope": "non-ascii"
}Result
{
"text": "Café <b>€5</b>",
"replaced": 2
}Input
{
"text": "<p>Café & €5 😀</p>",
"action": "decode"
}Result
{
"text": "<p>Café & €5 😀</p>"
}Questions
- Which characters must be escaped in HTML?
- Always & and <. Inside attribute values also the quote character. Escaping > and both quotes everywhere, as "special" does, is the safe habit.
- Is escaping enough to stop XSS?
- Only when the text is placed in HTML content or a quoted attribute. Text placed inside a script, a style or a URL needs different escaping.
- Why is the apostrophe written as '?
- It works everywhere, while the named form ' is not understood by some older HTML readers.
Related tools
- URL encoder and decoderPercent-encode text for use in a URL, or decode it. Works on one value or a whole URL.
url-encode - String bytes and code pointsShow the UTF-8, UTF-16 and UTF-32 bytes and the Unicode code points of a text.
string-escape-bytes - Base64 encoder and decoderEncode text to Base64 or decode it back, in the standard or URL-safe alphabet.
base64 - All hashes at onceCompute every supported hash of one input at once: MD5, SHA-1, SHA-2, SHA3-256 and BLAKE2b.
hash-all - Base32 encoder and decoderEncode text to Base32 (RFC 4648) or decode it back, with or without padding.
base32 - Base58 encoder and decoderEncode text or bytes to Base58 with the Bitcoin alphabet, or decode Base58 back.
base58