# HTML Sanitizer

Clean untrusted HTML by keeping only safe tags and attributes. The sanitizer, built on the sanitize-html library, removes scripts, event handler attributes, javascript: links, iframes and every element or attribute outside the allowed list, and keeps the text content. Choose common formatting, basic formatting or text only, and optionally allow images and classes.

## Frequently asked questions

### What does the default profile allow?

The default list of sanitize-html: headings, paragraphs, lists, blockquotes, code, tables, links and inline formatting such as b, i, em, strong and span. Links keep href, name and target. Images are removed unless you allow them.

### What does the basic profile allow?

Only a, b, blockquote, br, code, em, i, li, ol, p, pre, strong, u and ul, with href as the only attribute on links. It suits comments and short user content.

### Which link schemes are kept?

http, https, ftp, mailto and tel. Links with other schemes, such as javascript: or data:, lose their href, and protocol-relative links starting with // are removed too.

### What happens to the content of removed tags?

Disallowed tags are removed but their text is kept. The content of script, style and textarea elements and similar tags is removed completely, because it is not readable text.

### Is sanitizing once enough to prevent XSS?

Sanitize HTML when you store or render it, and escape everything else you insert into a page. Use the same allowed list on the server where the content is saved, because anything done only in a browser can be bypassed.

### What does text only do?

It removes every tag and keeps only the text, with HTML entities such as & left in place, so the result can be shown as HTML without markup.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad 433 tools for your AI agents through one MCP server.](https://multitaskai.com/?ref=oneclickpro)
