HTML escape / unescape
Try it interactively →POST /api/html-escapeEscape `<`, `>`, `&`, `"`, `'` to their HTML entities so user content can be safely embedded in HTML. Reverse direction also supported.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| text* | string | — | The text to escape (or unescape). |
| mode | enum (escape | unescape) | "escape" | `escape` (default) — convert specials to entities; `unescape` — reverse. |
Response
Modes: json. Cache: yes (24h TTL).
Code samples
Built from the escape-basic example.
curl -X POST https://api.xtract.bot/api/html-escape \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"text": "<a href=\"x\">Tom & \"Jerry\"</a>",
"mode": "escape"
}'