HTML sanitize
Try it interactively →POST /api/html-sanitizeSanitize untrusted HTML: strip `<script>`, event handlers, and dangerous attributes. Whitelist-based — only known-safe elements and attributes survive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| html* | string | — | Untrusted HTML to sanitize. |
| preset | enum (strict | rich) | "strict" | `strict` (default) for user-generated content; `rich` for article-style content (allows headings, code blocks, tables). |
| allowedTags | string | — | Optional JSON object mapping tag → array of allowed attributes. When set, replaces the preset's tag list entirely. |
| stripDisallowed | boolean | false | When true, drop disallowed tags entirely (with their content for <script>/<style>). When false (default), escape them as text. |
Response
Modes: json. Cache: yes (24h TTL).
Code samples
Built from the strip-script example.
curl -X POST https://api.xtract.bot/api/html-sanitize \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
-H "X-Api-Key: $XTRACT_API_KEY" \
-d '{
"html": "<p>Hello <script>alert(\"xss\")</script> world!</p>",
"preset": "strict"
}'